in reply to calling perl script from shell script

Is this code complete or did you just forget the fi?
Do a simple test like
/usr/bin/perl perlscript.pl ret=$? echo "Status String is $?" if [ $ret -eq 0 ] then echo "case A" else echo "case B" fi

pelagic
update
Your are testing the $? of the echo stmt ... ;))

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

Replies are listed 'Best First'.
Re: Re: calling perl script from shell script
by shilpam (Sexton) on Mar 26, 2004 at 13:30 UTC
    I tried the piece of code you have posted, but it gives me error:
    ./new_script.sh: ret: not found
    Status String is 1
    ./new_script.sh: test: argument expected



    Then I declared ret as $ret=$?, then I got another error:
    ./new_script.sh: =0: not found
    Status String is 1
    ./new_script.sh: test: argument expected


      Probably because you've got ret = $? or some other variant with spaces around the =. And the second is just plain wrong, as the $ is for interpolating in shell not a universal variable prefix. At any rate, it's not a perl problem; you need to look into something like Learning the bash Shell (ISBN 1565923472) or the Z shell intro.

      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.
        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