in reply to Re: Re: calling perl script from shell script
in thread calling perl script from shell script

Exactly what shell are you using? I run it on solaris, having used following code
#!/usr/bin/sh echo /usr/bin/perl perlscript.pl ret=$? echo "Status String is $?" if [ $ret -eq 0 ] then echo "case A" else echo "case B" fi
and it gave me
Status String is 0 case A

pelagic

-------------------------------------
I can resist anything but temptation.

Replies are listed 'Best First'.
Re: Re: Re: Re: calling perl script from shell script
by shilpam (Sexton) on Mar 29, 2004 at 07:07 UTC
    Thanks a lot!
    But how do I force it to exit with the status string?
    What I mean is that if the executing of perl pgm fails for some reason, I want it to be forced to exit the script. Else, if it is success, then ftp a file.
    exit $ret OR return $? doesn't work
      That could be done like that:
      #!/usr/bin/sh echo /usr/bin/perl perlscript.pl ret=$? echo "Status String is $?" if [ $ret -eq 0 ] then echo "case A" else echo "case B" fi echo going to exit shell with $ret exit $ret
      In this example we treat the return code of "echo" which is always 0 of course. But ist will also work when you remove the echoing and execute the perlscript instead.
      pelagic

      -------------------------------------
      I can resist anything but temptation.
        I have already tried that bit of code. My code is as follows.
        #!/usr/bin/sh cd dir_where_perl_pgm_exists perl my_perl_pgm.pl ret=$? if [ $ret -eq 0 ] then echo "Success" echo "FTP the report now" ftp -n << EOF open ftp_server user user_name password put some_file ls -l bye EOF else echo "Failure" echo "Exit the pgm" return $ret fi
        When I execute this code, it gives me error:
        syntax error at line 22: `end of file' unexpected