system command
| From: | ron clark | Date: | Mon, 23 Aug 2004 19:49:14 +0000 |
| Subject: | system command | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-194521@lists.php.net to get a copy of this message | ||
I an trying to add virus scanning to the file upload section of our portal using uvscan. The virus scanning is working properly using a system call , but I am having problems with formatting the output. I need to check the return value and if it is not a 0, I want to create a custom message. The problem is, when using system the output of the call is flushed to the browser before I can write the custom message so I have the uvscan message and then my custom message.
This is my code.
$uvscan_cmd = "/usr/local/bin/uvscan " . $_FILES['file']['tmp_name'];
$output = system("$uvscan_cmd" , $retval);
if ( $retval != 0) {
print "<br>A virus was found in your file <br>$output<br>";
exit;
}
This results in the following sent to the browser.
/var/tmp/phpBFaaIa Found the W32/Bagle.gen@MM!pwdzip virus !!!
A virus was found in your file.
Found the W32/Bagle.gen@MM!pwdzip virus !!!
How can get rid of the first line and still have data $output? I tried adding a 2 > &1 to the system call and tried redirecting the output to /dev/null. This got rid of the first line but also resulted in $output not having an output.
--
Ron Clark
System Administrator/Web Coordinator
Armstrong Atlantic State University