Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: calling perl script from shell script

by shilpam (Sexton)
on Mar 26, 2004 at 13:30 UTC ( [id://340005]=note: print w/replies, xml ) Need Help??


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

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


  • Comment on Re: Re: calling perl script from shell script

Replies are listed 'Best First'.
Re: Re: Re: calling perl script from shell script
by Fletch (Bishop) on Mar 26, 2004 at 13:47 UTC

    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.

Re: Re: Re: calling perl script from shell script
by pelagic (Priest) on Mar 26, 2004 at 14:05 UTC
    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
        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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://340005]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-24 12:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found