Hi,

Just wondering if someone could give me some help on this.

I have a form upload page with a php back end to move the file from the temp directory to a location e:\uploadedfiles.

I want to implement a virus check before moving the file but need to know how to return the code from the cli virus checker (sophos)

I assume I'll do an exec 'c:\program files\sophos\sav32cli.exe $temp_uploadname'

Here are the codes following the scan ;

SAV32CLI returns the following error codes:

0 If no errors are encountered and no viruses are found.
1 If the user interrupts the execution by pressing Esc.
2 If some error preventing further execution is discovered.
3 If viruses or virus fragments are discovered.

How would I return the codes to see if a virus is found?

Thanks.

    I did read the manual but had a problem which is why I posted here.

    Gees these forums used to be amazingly helpful!

    Anyway, If anyone else fancies giving me some tips here's the code ;

     <?
    
     $filename = "c:\\msizap.exe" ;
     exec("c:\program files\sophos\sophos anti-virus\sav32cli.exe $filename", $output, $result);
    
    
    print_r($output);
    
    echo "<br>above is output, below should be result<br>" ;
    
        print_r($result);
    
    
     ?>

    I get ;

    CGI Error
    The specified CGI application misbehaved by not returning a complete set of HTTP headers.

      ok so I've got it working using ;

       <?
      
       $filename = "c:\\eicar.com" ;
      
        exec("\"c:\\program files\\sophos\\sophos anti-virus\\sav32cli.exe\" $filename", $output, $result);
      
      
      print_r($output);
      
      echo "<br>above is output, below should be result<br>" ;
      
          print_r($result);
      
      
       ?>

      but if the file name has a space in it, i get the same error as before.

      I tried \"$filename\" but that results in the same error.

        How do pass an argument to sav32cli that contains white spaces (directly from the console, not PHP)? When you get that to work, do the same in php.

        And if all else fails, don't assign file names containing argument separator characters.

        Gees these forums used to be amazingly helpful!

        Still are. I doubt that line will encourage people though.

          "c:\program files\sophos\sophos anti-virus\sav32cli.exe" "c:\ei car.com"

          works fine when passed from a command line.

            And do you pass that as c:\ as well?

            I do see the double backslash in yourfilename in the code above, but that one does not contian any whitespace.

              Yep, I pass that as c:\ as well.

              Ah well, I've got around it by using the php upload [tmp_name] which is 8 chars!

              I'm interested to know why it doesn't work this way though.

                markfc wrote:

                If anyone else fancies giving me some tips here's the code ;

                <?
                
                $filename = "c:\\msizap.exe" ;
                exec("c:\program files\sophos\sophos anti-virus\sav32cli.exe $filename", $output, $result);
                
                
                print_r($output);
                
                echo "<br>above is output, below should be result<br>" ;
                
                    print_r($result);
                
                
                 ?>

                I get ;

                CGI Error
                The specified CGI application misbehaved by not returning a complete set of HTTP headers.

                I'm sorry; I didn't know any of this (I wonder why not?). I answered the question you asked:

                How would I return the codes to see if a virus is found?

                Silly me.

                  Write a Reply...