System call in CGI not work


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting System call in CGI not work
# 1  
Old 01-17-2008
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;
# 2  
Old 01-17-2008
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.
# 3  
Old 01-17-2008
If possible, you can rewrite your program to include code from A.pl
# 4  
Old 01-17-2008
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
# 5  
Old 01-17-2008
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
# 6  
Old 01-17-2008
did you check the web server logs yet?
# 7  
Old 03-18-2008
Quote:
Originally Posted by frank_rizzo
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

Commands to call script work from command line but not from Cron entry

My first post evidently did not materialize so I posted it again: Runnning a cron job every 5 mins to send data files to a state facility. My original cron entry at worked fine: 01,06,11,16,21,26,31,36,41,46,51,56 * * * * /home/sftpuser/stateinoc-from-appname.ksh Somewhere I have a... (1 Reply)
Discussion started by: Skyybugg
1 Replies

2. Programming

C:system call

Hi I'm studing the system call. I've written a small program that return the time spent in doing some operations. Now I'd like to write one that return the time spent in user mode of a process. I'm reading that i should use the tms struct: clock_t times(struct tms *buf); struct tms {... (2 Replies)
Discussion started by: Dedalus
2 Replies

3. Shell Programming and Scripting

Perl cgi script to call bash script?

Novice to perl here. I have created a simple web page in perl, with only one submit button. I would like to execute a bash script on the same server when this button is clicked on. Is this possible in perl? I have spent a few days researching this and am unable to find any useful information.... (0 Replies)
Discussion started by: pleonard
0 Replies

4. Shell Programming and Scripting

Run system command in perl cgi

Hi guys, got a problem with a perl cgi script over here. I need it to run a system command to get the status of a process. Unfortunately the process is owned by a specific user and only this user can get its status. So i tried running the command from the perl cgi with "su", but then i get the... (12 Replies)
Discussion started by: polki
12 Replies

5. Shell Programming and Scripting

call shell script from perl cgi script problem

hi,, i have perl scipt with line : system('./try.sh $t $d $m'); in shell scipt try.sh i have the line: echo $1 its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies

6. AIX

lvm_queryvg call does not work properly and results in a sudden memory rise.

On AIX 5.3 host, the lvm_queryvg call does not work properly and results in a sudden memory rise. This is happening on one particular host and the call works fine on another host. Is this a known issue and is there any patch available for this? (0 Replies)
Discussion started by: sandiworld
0 Replies

7. HP-UX

pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3)

As per the man page, pstat_getdisk() call returns the number of instances, which could be 0 upon successful completion, otherwise a value of -1 is returned. Please have a look at this sample program -> #include <stdio.h> #include <sys/pstat.h> int main() { int j = 0, ret; struct... (2 Replies)
Discussion started by: sandiworld
2 Replies

8. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies

9. UNIX for Dummies Questions & Answers

does this variable call work--Korn

I am new to the UNIX environment, but not to programming. My intention is to create a 2D array and print it. Since the Korn Shell does not support that kind of variable, the following is my solution right now. I have created a group of variables as follows: table00 table01 table02 table10... (2 Replies)
Discussion started by: morkfard
2 Replies
Login or Register to Ask a Question