Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: CSH script that calls a perl script

by hippo (Curate)
on Oct 16, 2012 at 22:07 UTC ( #999434=note: print w/ replies, xml ) Need Help??


in reply to CSH script that calls a perl script

No, there is no way for a called (forked or spawned) program to export values back up the calling chain. You have only two options for passing any sort of data back up the chain. The first is the return value, but you really ought not to use that for arbitrary data values. Its use is so ingrained as a status flag for the completion of the child that to use it for anything else would just cause confusion and other problems in the long term. So, instead you might want to use the second option which is IPC or general I/O, neither of which I'm guessing is trivial in csh.

Which brings me neatly to the next point. You have read csh programming considered harmful haven't you? It's over 15 years old now and is as true today as it was back then. I would therefore humbly suggest that you would be much better off in both the short term and the long term if you were to bite the bullet and rewrite your csh script as perl for all the reasons mentioned in Tom's paper as well as to make the passing of data between your pieces of perl code so much simpler.

Of course, that's probably not what you wanted to hear.


Comment on Re: CSH script that calls a perl script
Re^2: CSH script that calls a perl script
by mark4444az (Sexton) on Oct 16, 2012 at 22:19 UTC
    Both no's on your questions I'm afraid. Actually, if I could evaluate a return value as a 1 or 0 I think that would work. That way I could shut the action down from the csh. I'm not sure how exactly to accomplish that but I think that would get me through my current dilemma. I tried using perl only and I may not have time to do that. The main problem there is that it produces a log file from another exe and so far perl does not seem to be working for that.

      Would you be happy with your Perl script returning 0 for success and 255 for failure? If so, take note...

      $ perl -e'die'; echo "GOT $?" Died at -e line 1. GOT 255 $ perl -e'exit'; echo "GOT $?" GOT 0
      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2014-12-22 10:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (114 votes), past polls