Re: WinNT, PHP4, IIS4, exec() Nothing Happens at all!

From: Date: Sun, 15 Apr 2001 13:05:57 +0000
Subject: Re: WinNT, PHP4, IIS4, exec() Nothing Happens at all!
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-6745@lists.php.net to get a copy of this message
""Dave Faulkner"" <dave@comlink.net.au> wrote in message news:9bb3cf$ck0$1@toye.p.sourceforge.net... > Hi People!, > > this seems like an age old question that just doesnt seem to be able to get > solved. I too have a problem calling NT programs from within my PHP script. > Hoepfull there is a guru out there who will be able to tell me what i am > doing wrong. > > As the subject states, i am running WinNT4, SP6, IIS4, PHP4. I have a web > page that users can use to upload pictures to my server. This script it > pasted below > > <? > > include "header.inc"; > if ($image_name != "") { > copy("$image", "../aviation/uploads/$image_name") or die > ("Couldn't copy the > file."); > > } else { > > die("You forgot to add a filename"); > > } > > $img_location = "aviation/uploads/$image_name"; > > $db = mysql_connect("user", "password") or die("Can't connect to server."); > mysql_select_db("database", $db) or die("Can't select database."); > > > > $insert_data = "INSERT INTO table (image, fname, lname, email, location, > rego, remarks, airline) VALUES ('URL/$image_name', '$fname', > '$lname', > '$email', '$location', '$rego', '$remarks', > '$airline')"; > > mysql_query($insert_data) or die("Couldn't insert data."); > > system("echo File has been uploaded! | blat - -s \"$image_name > uploaded --\" -t $email"); > > ?> > > This php file is called from another HTML file. All this info is passed into > the database, and at the same time the image itself is copied to another > directory on the server. All that works excellently!!!. However, what i want > to do is, i want to add some form of compression to the picture (before or > after doesnt matter) when it is copied to the directory. The idea behind > this is so that when people come to my web site and query the database on > pictures, they are compressed a little to save download time. > > PROBLEM: I have tried all sorts of things from cjpeg/djpeg to trying to call > an expternal program called "autobatchit.exe" with the php file to add > compression etc. > > Below is some of the stuff i have tried: > > // exec("I:\Perl\bin\cjpeg.exe -quality 30 -progressive $image_name"); > // exec("c:/autobatchit!/autobatchit.exe"); > // exec("c:\autobatchit!\autobatchit.exe"); > // exec("c:\command.com /k autobatchit.bat" ); > > And other variations which i have not added. The results are varying. If i > use "cmd" int he exec() anywhere, the script seems to halt at that point and > wont go any further. However all of the above lines result in NOTHING > happening at all!........if i look at the task manager while i run the > script, nithing comes up at all in relation to what i am trying to execute. > > SO thats about it!!.............the persont hat solves the problem for me > gets a free freddo!!! > > In all honesty i have tried a lot of different stuff that just doesnt seem > to work. If anyone can help me out with this i owuld be very appreciative. I > have been trying for days to ge tthis working with no luck. It is quite > possible that i have missed something very simple as i have only been > working with php (or any coding for that matter) for about two weeks now. > > Thanks in advnace for any help anyone can give me > > Regards > > Dave Faulkner Dave here is a simple script that calls an batch file the first example does not work using double quotes the second example does work using single quotes. <? print "<HTML>\r\n"; print "<HEAD>\r\n"; print "<TITLE> EXEC() TEST</TITLE>\r\n"; print "</HEAD>\r\n"; print "<BODY>\r\n"; exec("D:\Xitami\temp\cleanup.bat", $returnstring,$returnvar); print "Return var: ".$returnvar."<BR>\r\n"; print "Printing output ".count($returnstring)." lines:<BR>"; print "\r\n"; while (list($line, $text) = each($returnstring)) { print "[$line] $text<br>"; } print "</BODY>\r\n"; print "</HTML>\r\n"; ?> ############# <? print "<HTML>\r\n"; print "<HEAD>\r\n"; print "<TITLE> New Document </TITLE>\r\n"; print "</HEAD>\r\n"; print "<BODY>\r\n"; exec('D:\Xitami\temp\cleanup.bat', $returnstring,$returnvar); print "Return var: ".$returnvar."<BR>\r\n"; print "Printing output ".count($returnstring)." lines:<BR>"; print "\r\n"; while (list($line, $text) = each($returnstring)) { print "[$line] $text<br>"; } print "</BODY>\r\n"; print "</HTML>\r\n"; ?> the .bat file has del pipe*.* del *.tmp as per-perl the single quote say's 'Yes really use this like this'. in earlier post I said that one has to escape the backslash but this does not appear to be the case with PHP/Apache. The two problems I can think of (Not having NT, IIS) are permission settings in both NT and IIS. try running the EXEC() on something that stays in /root/webpages/ and see if you get the same results. I wish I had more cpu time with nt but the only time I have on it is setting up permissions for network conections. hope something clicks for ya soon have fun I am Patrick

« previous php.windows (#6745) next »