Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

TCL to Perl

by RollyGuy (Chaplain)
on May 16, 2003 at 17:21 UTC ( #258705=perlquestion: print w/replies, xml ) Need Help??

RollyGuy has asked for the wisdom of the Perl Monks concerning the following question:

At work here we are converting a tcl script into a perl script. One of the interesting lines of the tcl script is the following:
set f_handle [open {|./script.pl >& script.log} a] -----Some deleted code-------- if [catch {close $f_handle} ] { send_mail "Script had a problem, returned non-zero status!." } else { send_mail "Script ok." }
What this code does is open a process and run "./script.pl >& script.log" alongside of the tcl script. Then later, the "catch" function waits for the script to finish (if it hasn't) and grabs the exit value of "script.pl". Is there a way to do a similar thing in perl? Remember that the "script.pl" actually runs in parallel with the tcl script.

Replies are listed 'Best First'.
Re: TCL to Perl
by mr_mischief (Monsignor) on May 16, 2003 at 19:16 UTC
    Yes, there is.

    You can manually fork() and exec() your child script then wait() for it to end and check the $? variable for its status.

    Christopher E. Stith
    use coffee;
Re: TCL to Perl
by Aristotle (Chancellor) on May 17, 2003 at 15:13 UTC
    From perldoc -f close:
    If the file handle came from a piped open "close" will additionally return false if one of the other system calls involved fails or if the program exits with non-zero status. (If the only problem was that the program exited non-zero $! will be set to 0.)
    See the perldoc for some example code and more explanation.

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://258705]
Front-paged by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2022-08-15 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?