The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
c system call rangaswamy High Level Programming 1 02-19-2008 10:53 AM
lvm_queryvg call does not work properly and results in a sudden memory rise. sandiworld AIX 0 11-14-2007 10:57 PM
pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3) sandiworld HP-UX 2 10-25-2007 07:39 AM
how to differentiate system call from library call muru UNIX for Advanced & Expert Users 2 07-19-2007 08:20 PM
does this variable call work--Korn morkfard UNIX for Dummies Questions & Answers 2 07-10-2001 07:59 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-16-2008
Registered User
 

Join Date: Jul 2004
Posts: 9
System call in CGI not work

I have a cgi script that calls a perl script (A.pl) to do something in backgroup, when run that perl script in command everything works fine, but when it calls by the CGI script, nothing works. I have tried another perl script (B.pl not cgi) calls A.pl, and it works fine.
The A.pl is chmod 777,

Can someone here help?

Thank you!


Here is my cgi calling A.pl:
#!/usr/bin/perl -w
#
use CGI;
$mycgi = new CGI;

print $mycgi->header;
print $mycgi->start_html(
-title=>'System Tes'',
-BGCOLOR=>'#FFFFCC');


# do something here

# system calls both don't work
system("/mypath/A.pl");

unless (system("/mypath/A.pl")) {
print "system calls failed: $!"; # not seeing this msg from browser
}


# print HTML message here, is seen from browser

print $mycgi->end_html;
exit;
Reply With Quote
Forum Sponsor
  #2  
Old 01-16-2008
Resident BOFH
 

Join Date: Dec 2007
Posts: 262
What do you mean by "nothing works", do you get an error ? 5xx HTTP error perhaps? Has this ever worked? Are other cgi scripts working ok?

You should really never need to chmod 777 any script, especially a CGI script.

add this to the top of your script. I suggest using this in all of your scripts.

Code:
use strict;
Check your web server logs. The errors should be logged there. This is the first place you should look.
Reply With Quote
  #3  
Old 01-16-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
If possible, you can rewrite your program to include code from A.pl
Reply With Quote
  #4  
Old 01-16-2008
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Quote:
unless (system("/mypath/A.pl")) {
print "system calls failed: $!"; # not seeing this msg from browser
}
Check the perms again ( you said that it has been checked )
the print statement has to be wrapped as a line to html page,
use "<br>" tags to see the error message in the html page
What is the return code of system function call ?

One more thing, make sure, it had happened several times,
make sure of the absolute path of the filename
Reply With Quote
  #5  
Old 01-17-2008
Registered User
 

Join Date: Jul 2004
Posts: 9
My cgi script is working fine. Paths in system calls are correct.

Here are my system calls from a cgi script:

unless (system("/mypath/A.pl") == 0 ) {
print "<br><br>1 system calls failed $?<br>";
}
unless (system("/bin/cat /mypath/TMP.txt > /mypath/fileA.txt"") == 0) {
print "<br><br>2 system calls failed $?<br>";
}
unless (system("/bin/cp -f /mypath/fileA.txt /mypath/fileB.txt") == 0) {
print "<br><br>3 system calls failed $?<br>";
}

Return codes seen from browser:

1 system calls failed 3328


2 system calls failed 65280


3 system calls failed 256
Reply With Quote
  #6  
Old 01-17-2008
Resident BOFH
 

Join Date: Dec 2007
Posts: 262
did you check the web server logs yet?
Reply With Quote
  #7  
Old 03-18-2008
Registered User
 

Join Date: Mar 2008
Posts: 1
Quote:
Originally Posted by frank_rizzo View Post
did you check the web server logs yet?
I'm having the same problems, and I don't think I have access to the web server logs.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0