Click to See Complete Forum and Search --> : Calling URL from a script


mstembri3
03-29-2002, 11:29 AM
I have an upload function on a website that will be used to upload, scan, archive, then send to an email address.

I'm stuck on getting the web page (a php doc) to work with a bash script.

I'd like to have the php page call the bash script with a system() function, and then have the bash script call the same php page when it is done so the user can see the result of the operation.

Is this possible? If I can get the bash script to call a URL so that it will display in the users browser I think I can make it work. But I am completely in the dark as to whether this is possible, and how it can be done.

Any and all help/pointers appreciated.

Stuka
03-29-2002, 11:37 AM
I don't think it'll work like you want - but PHP can do most of the work you'd need I think, so the bash script ought not be necessary - if that's the case, just write the PHP script and call it...what are you trying to do that needs a bash script?

mstembri3
03-29-2002, 12:30 PM
If I were to write it in php it might look like this:


$path = "/var/www/html";
$filename ="$path/upload/$fnum.bat";
$bat = "
@ECHO OFF
IF NOT EXIST C:\TEST\TEST.DAT COPY C:\TEST.DAT C:\TEST\TEST.DAT
";

system ("mkdir $path/upload/$fnum"); // create temp directory

$myFile= fopen($filename,'w+'); // Open the file for writing
if(!$myFile){ echo "File could not be opened."; exit; }
fputs($myFile, $bat); // Write the data ($bat) to the text file
fclose($myFile); // Closing the file after writing data to it

$command = "/usr/local/rav8/bin/ravav -AQ--quarantine=$path/upload/infected $path/upload/$form_data_name";
system($command, $returnvalue);
if ($returnvalue==1) { // note: ravav will return a value of 1 if the file is clean and no problems were encountered
system "/usr/local/bin/pkzip25 -add -sfx=jrdos $path/download/$fnum $path/upload/$fnum/* > /dev/null";
// note the above line creates a $fnum.exe self extracting archive and places it in the appropriate directory.
system ("rm -rf /var/www/html/upload/$fnum"); // del temp dir
echo "Files scanned, packed and are ready for download.";
} else {
echo "Infected file. Operation aborted.";
}


[ 29 March 2002: Message edited by: mstembri3 ]