evaluating success of command run with backticks

R

Ravi Parimi

Hi,
Is there a way to know if a command executed via backticks was
successful or not?

my $res = `shell_command`;

What would I have to check to obtain this information? Would it be one of
$? variables? Any pointers to perldocs will be helpful.

Thanks a lot,
--ravi
 
J

James Willmore

Hi,
Is there a way to know if a command executed via backticks was
successful or not?

my $res = `shell_command`;

What would I have to check to obtain this information? Would it be one of
$? variables? Any pointers to perldocs will be helpful.

Thanks a lot,
--ravi

(long link to recently asked question that may answer your question)

http://groups.google.com/groups?hl=...lr=&ie=UTF-8&oe=utf-8&scoring=d&start=30&sa=N

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Mickey Mouse wears a Spiro Agnew watch.
 
B

Ben Morrow

Ravi Parimi said:
Is there a way to know if a command executed via backticks was
successful or not?

my $res = `shell_command`;

What would I have to check to obtain this information? Would it be one of
$? variables?
^^
You have answered your own question :)
Any pointers to perldocs will be helpful.

perldoc perlvar

Ben
 
P

Paul Lalli

Hi,
Is there a way to know if a command executed via backticks was
successful or not?

my $res = `shell_command`;

What would I have to check to obtain this information? Would it be one of
$? variables? Any pointers to perldocs will be helpful.

Thanks a lot,
--ravi


perldoc perlvar
look up $? just as you thought. It contains the status of any program
started with system(), backticks, wait(), waitpid(), or pipes.


Paul Lalli
 
P

Peter Sundstrom

Ravi Parimi said:
Hi,
Is there a way to know if a command executed via backticks was
successful or not?

my $res = `shell_command`;

What would I have to check to obtain this information? Would it be one of
$? variables? Any pointers to perldocs will be helpful.

Congratulations!!!

You've earned an entry in the Perl SAQ.

http://www.ginini.com/perlsaq.html
 
M

Mark Jason Dominus

(long link to recently asked question that may answer your question)

http://groups.google.com/groups?hl=...lr=&ie=UTF-8&oe=utf-8&scoring=d&start=30&sa=N

In these Google URLs, there is a lot of extraneous information that
you don't need to pass along. For example, the 'hl=en' tells Google
that you want to use the English interface. There's no need to
include this in your news article. Usually you only need the
'threadm' or 'selm' component, as:

http://groups.google.com/[email protected]

Voila.
 
J

James Willmore

In these Google URLs, there is a lot of extraneous information that
you don't need to pass along. For example, the 'hl=en' tells Google
that you want to use the English interface. There's no need to
include this in your news article. Usually you only need the
'threadm' or 'selm' component, as:

http://groups.google.com/[email protected]

Voila.

Thanks.

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Very few profundities can be expressed in less than 80
characters.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top