Okay, I thought the hack of doing this (scan.sh) might work, but running some timing tests, it's apparent that it's not... The more IP addresses I schedule to scan, the longer it takes to return my browser page.
#!/bin/sh /bin/scan & And while if I run it on the command line in bash, it works just fine, PHP seems to STILL wait until the /bin/scan is done. UGH! I tried this exec() suggestion and that didn't work right either. exec("/bin/scan & > /dev/null 2>/dev/null"); Then I thought I might try this http://us2.php.net/manual/en/function.pcntl-fork.php But frustratingly, "Process Control support in PHP is not enabled by default. You have to compile the CGI or CLI version of PHP with --enable-pcntl configuration option when compiling PHP to enable Process Control support. " and I'm using RPMs without the ability to recompile, as this PHP code is to be deployed on many boxes that are all ghost images of the one I'm developing on. Rasmus or someone in the know, please tell me how I can fire off a process without having PHP wait for the return. I'm doing: $time_start = getmicrotime(); echo "executing scan.sh<BR>"; exec("/www/datasafe/scan.sh &"); $time_end = getmicrotime(); echo "command took: ".($time_end - $time_start)." seconds<BR>"; And I see things like 7, 14 and 28 seconds depending on if I use a /24, /22, /21 CIDR range for the IP address subnet. Furthermore, calculating the list of IP's to put in the db doesn't take more than a second or two in all cases. And I don't think that the mySQL overhead is taking up the other time. Daevid. > -----Original Message----- > From: Marek Kilimajer [mailto:[EMAIL PROTECTED] > Sent: Saturday, October 11, 2003 5:02 AM > To: Daevid Vincent > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] How to fire off a unix command WITHOUT > waiting for it to return (I want to use &) > > Try > exec("/bin/scan & > /dev/null 2>/dev/null"); > > Daevid Vincent wrote: > > How can I cause PHP to fire off a unix program and NOT wait > for a reply. > > Basically I want to use the "&" love the unix provides, but > it seems that > > exec, passthrough, system and even ` ` all wait for a > return despite my > > putting something like exec("/bin/scan &"); or `/bin/scan &` > > > > *sigh* > > > > The sitch is that I'm scanning/pinging/nmap a HUGE amount > of IP addresses. > > Perhaps 254 - 65000 or more individual iP addresses. We > have a multithreaded > > scanner that we wrote in C that can to this quickly, but > it's still a wait. > > It pulls from a db the ips to scan and sets their up/down > flags. My php > > scheduler page queries to get the ones that are up. > > > > So as you see, I don't want to wait for a return code, I > know the status via > > the db and how many rows are done/need to be done. > > > > Daevid Vincent. > > http://daevid.com > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php