How to capture the exit code of a shell script in a perl script.?

hi,

i want to pop up an alert box using perl script. my requirement is.
i am using a html page which calls a perl script. this perl script calls a shell script.. after the shell script ends its execution, i am using exit 0 to terminate the shell script successfully and exit 1 to terminate the shell script when an error occurs in the shell script. i want to capture this exit code in the perl script. and depending on the value 0 or 1, i want to pop up an alert box with success or failure message respectively. any1 is having any idea. its urgent please..

use system() method of perl

ya i used system(), but i need to generate the output of the shell script to a log file also. i do not know how to send the output of the shell script to a log file from system command.

$return = system("sh", "shell_script.sh", $NAME, $FileName);

i want to send the output to a log file..

$return = system("sh", "shell_script.sh", $NAME, $FileName, >/app/home/$NAME/output.log, 2>/app/home/$NAME/error.err);

but the command gives an error.

ok i got the where i did wrong.. i need to include " >/app/home/$NAME/output.log " and " 2>/app/home/$NAME/error.err " in double quotes.

---------- Post updated at 03:30 PM ---------- Previous update was at 03:23 PM ----------

no, its not creating a log file.

It works fine for me

[root@www test]# ll
total 16
-rw-r--r-- 1 root root  0 Aug 26 23:19 error.err
-rw-r--r-- 1 root root  0 Aug 26 23:19 output.log
-rwxr-xr-x 1 root root 96 Aug 26 23:19 script.pl
-rwxr-xr-x 1 root root 48 Aug 26 23:18 script.sh
 
[root@www test]# 
[root@www test]# 
[root@www test]# cat script.sh
#!/bin/bash
echo stderr >&2
echo hello
exit 0
[root@www test]# cat script.pl
#!/usr/bin/perl
 
my $ret = system("./script.sh > output.log 2> error.err");
$ret = $ret >> 8;
print "$ret\n";
 
[root@www test]# perl script.pl
0
[root@www test]# cat error.err
stderr
[root@www test]# cat output.log
hello
[root@www test]#