httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julian Grunnell" <julian.grunn...@pipex.net>
Subject [users@httpd] Wierd CGI problem
Date Mon, 13 Dec 2004 08:48:24 GMT
Hi - after some help / advice with a CGI script that refuses to run,
well sort of ...
 
Platform:
Sun E220R
Solaris 9
Apache 1.3.33 - All built with DSO support.
Mod SSL
PHP 4.3.9
Mod SQL_Log
Mod Throttle.
 
I have a CGI script that is meant to just cat an sql file & then pipe
this through to a connection to a mysql DB to update a table. Simple
enough. The script is as follows, these are NOT the actual MySQL
usernames / passwords / database names etc !!
 
cat dbupdate.cgi
#!/usr/bin/perl
#
print "Content-type: text/plain\n\n";
print "Updating DB...\n";
print "\n";
chdir("/path-to-sql-folder/sql/");
$cmd = "/usr/bin/cat ./rebuild.sql | /local/mysql/bin/mysql
--local-infile=1 -uusername -ppassword -hsql-server database-name";
#$cmd = "/usr/bin/cat ./rebuild.sql"; ## TEST COMMAND
print "Doing $cmd\n";
print "\n";
system ($cmd);
print "Completed DB Update\n";

Now calling the script thus,
http://www.whatever.com/cgi-bin/dbupdate.cgi appears to work, BUT the
"$cmd" line is completely ignored? Absolutely NO Apache errors & NO
MySQL errors. The actual update should take atleast 60 seconds to run.
But just takes about 1/2 a second and says it's "Completed DB Update".
 
If I switch the "$cmd" lines around so the "TEST COMMAND" runs it does
work? ie. it cats the "rebuild.sql" file. I have tried using the full
path names to all files and got the same result. As well as not only
just doing a "cat" command as the test but then piping this to another
command, eg. "/usr/bin/cat ./rebuild.sql |grep text" and that command
works fine.
 
What I can't understand is the fact that I can run this script from the
command line as the user that Apache runs as & it works? I thought this
would fail as well. I'm trying to run the exact same script, albeit
using a different medium to do so?
 
Any help appreciated as I'm going crazy over this!
 
Thanks - J.

Julian Grunnell
3rd Line Technical Support
PIPEX

Telephone: 0113 302 1005
Mobile: 07803 649593
Website: http://www.pipex.net <http://www.pipex.net/>  

 

Mime
View raw message