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

How to know the exit status of sub-commands running with backticks in Perl.

by kkurnala (Initiate)
on Apr 05, 2012 at 21:54 UTC ( [id://963750]=perlquestion: print w/replies, xml ) Need Help??

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

Dear Perl Monks, I am a novice in perl and currently stuck with a problem. please help. My code has lines like:

}elsif ($branchurl =~ /sites/) { $outfile_merge = 'STARTING MERGE FOR sites\n================== +================\n'; $branchurl =~ /sites\/(.+)\/branches/i; print "$1"; $outfile_merge = `cd trunk/sites/$1; svn merge --dry-run $bran +churl .`; print " 5 - $outfile_merge\n"; }

In the above snippet, I want to know if there is an error with the cd command or svn merge command and come out of the loop with a error message Can one of you recommend what best I can do please? Thanks a tonne !!

  • Comment on How to know the exit status of sub-commands running with backticks in Perl.
  • Download Code

Replies are listed 'Best First'.
Re: How to know the exit status of sub-commands running with backticks in Perl.
by ikegami (Patriarch) on Apr 05, 2012 at 21:55 UTC

      can you please explain a little more? Thanks :)

        You may wish to read perlvar in addition to the system documentation already mentioned. Search for $?.

        Note too that if backticks fails it will set the special variable $!.

        True laziness is hard work

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-16 07:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found