Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > system calls re...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 10809 of 11948
Post > Topic >>

system calls return code

by ultra.star.x@[EMAIL PROTECTED] (Ultra Star X) Mar 27, 2008 at 03:50 AM

I am really going crazy here. I have the following system call that I
would like to run from perl:
  "ls *.txt | xargs cat > out"
if *.txt does not exist then I expect to get an exit code different
from 0.

So to test I do:

use strict;

my $f = "file_which_does_not_exist";

# method 1
print "test 1\n";
qx(ls $f | xargs cat);
print $?,"\n";

#method 2
print "test 2\n";
system("ls $f | xargs cat");
print $?,"\n";

Both calls return 0  instead of returning error as 'ls' fails.
Help. How do I do this ?
Would 'open' help ?

C.
 




 4 Posts in Topic:
system calls return code
ultra.star.x@[EMAIL PROTE  2008-03-27 03:50:38 
Re: system calls return code
pangj@[EMAIL PROTECTED]   2008-03-27 20:10:28 
Re: system calls return code
sandy_saydakov@[EMAIL PRO  2008-03-27 08:03:24 
Re: system calls return code
ultra.star.x@[EMAIL PROTE  2008-03-27 10:24:55 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 7 16:18:15 CDT 2008.