httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boyle Owen" <Owen.Bo...@swx.com>
Subject RE: [users@httpd] Wierd CGI problem
Date Mon, 13 Dec 2004 13:47:29 GMT
> -----Original Message-----
> From: Julian Grunnell [mailto:julian.grunnell@pipex.net]
> Sent: Montag, 13. Dezember 2004 13:04
> To: users@httpd.apache.org
> Subject: RE: [users@httpd] Wierd CGI problem
> 
> 
> Thanks Owen ... now were going places, I don't reckon' Perl will catch
> on.
> 
> Anyway return code given is 35072. Wheras all the other test commands
> give 0. Even running the correct script from the command line 
> gave a 0.
> So only through a browser did it fail.

your CGI environment is not the same as a login shell. In particular, environment variables
are usually not set (unless you inherit them with "PassEnv"). Do you need ORACLE_HOME set
or something?

> 
> Now to try and find out what 35072 is all about!

Try google... looks like it ocurs in the context of a DB query...

Rgds,
Owen Boyle
Disclaimer: Any disclaimer attached to this message may be ignored. 

> 
> Thanks for your help as ever Owen.
> 
> J.
> 
> -----Original Message-----
> From: Boyle Owen [mailto:Owen.Boyle@swx.com] 
> Sent: Monday, December 13, 2004 10:41 AM
> To: users@httpd.apache.org
> Subject: RE: [users@httpd] Wierd CGI problem
> 
> 
> Plain text please...
> 
> Your problem is not with apache, it's with your Perl code.
> 
> You are running the command using the system() function. 
> However, you do
> not check the return code of this call. The system() function forks a
> new process to execute the command - that's why you don't see anything
> in apache's logs; the command executes in a different shell and its
> output goes to bit heaven. The return code is ignored too so you don't
> even know if it worked or not. 
> 
> At the very least, check the return code, eg:
> 
> my $rc = system($cmd);
> print STDERR "return code = $rc\n";
> 
> If it's anything but 0, you have a problem.
> 
> If you want to trap the output, use backticks, eg;
> 
> my $op = `$cmd`;
> print STDERR "output = $op\n";
> 
> Rgds,
> Owen Boyle
> Disclaimer: Any disclaimer attached to this message may be ignored. 
> 
> PS  - output to STDERR will arrive in the error log.
> 
> -----Original Message-----
> From: Julian Grunnell [mailto:julian.grunnell@pipex.net]
> Sent: Montag, 13. Dezember 2004 09:48
> To: users@httpd.apache.org
> Subject: [users@httpd] Wierd CGI problem
> 
> 
> 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
> 
> This message is for the named person's use only. It may contain
> confidential, proprietary or legally privileged information. No
> confidentiality or privilege is waived or lost by any mistransmission.
> If you receive this message in error, please notify the 
> sender urgently
> and then immediately delete the message and any copies of it from your
> system. Please also immediately destroy any hardcopies of the message.
> You must not, directly or indirectly, use, disclose, 
> distribute, print,
> or copy any part of this message if you are not the intended 
> recipient.
> The sender's company reserves the right to monitor all e-mail
> communications through their networks. Any views expressed in this
> message are those of the individual sender, except where the message
> states otherwise and the sender is authorised to state them to be the
> views of the sender's company. 
> 
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server
> Project. See <URL:http://httpd.apache.org/userslist.html> for 
> more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP 
> Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 
> 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message