Re: system calls return code

2008-03-27 Thread ultra . star . x
Thank you very much for explaining. I will try what Sandy suggested. I had tested at the command line already just as Jeff did. The confusion came from the fact that I had tried it in csh and in csh, doing the "ls |xargs cat" returned 1. Annoying. C. -- To unsubscribe, e-mail: [EMAIL PROTEC

Re: system calls return code

2008-03-27 Thread Sandy
On 27 мар, 03:50, [EMAIL PROTECTED] (Ultra Star X) wrote: > 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: > >

Re: system calls return code

2008-03-27 Thread Jeff Pang
This is because you send ls's output to a pipe, and the command on the right of the pipe get executed successfully. Try this test on shell: -bash-3.00$ ls |xargs cat ls: : No such file or directory -bash-3.00$ echo $? 0 -bash-3.00$ ls ls: : No such file or directory -bash-3.00$ ec

system calls return code

2008-03-27 Thread ultra . star . x
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

Re: Capturing an external program return code

2007-05-01 Thread Mumia W.
On 05/01/2007 07:09 PM, Vladimir Lemberg wrote: [...] system ( "$program -f $program.cfg" ); if ($? == -3) { [...] You're facing two problems: the return value for system() needs to be shifted right by eight bits; and that value is provided in "unsigned" form, so you have to massage it: m

Re: Capturing an external program return code

2007-05-01 Thread Vladimir Lemberg
Hi Tom, That was very helpful. Thanks a lot, Vladimir - Original Message - From: "Tom Phoenix" <[EMAIL PROTECTED]> To: "Vladimir Lemberg" <[EMAIL PROTECTED]> Cc: Sent: Tuesday, May 01, 2007 5:36 PM Subject: Re: Capturing an external program return cod

Re: Capturing an external program return code

2007-05-01 Thread Tom Phoenix
On 5/1/07, Vladimir Lemberg <[EMAIL PROTECTED]> wrote: My script is executing external program, which returns code i.e 0, -1, -2, -3 etc if ($? == -3) { This is not working. Nothing is printing to the log file when I'm simulating -3 code. If I print $?, it shown 65280. The value in $? i

Re: Capturing an external program return code

2007-05-01 Thread Chas Owens
On 5/1/07, Vladimir Lemberg <[EMAIL PROTECTED]> wrote: snip This is not working. Nothing is printing to the log file when I'm simulating -3 code. If I print $?, it shown 65280. snip from perldoc -f system: if ($? == -1) { print "failed to execute: $!\n"; } elsif ($? & 127) {

Capturing an external program return code

2007-05-01 Thread Vladimir Lemberg
Hi All, My script is executing external program, which returns code i.e 0, -1, -2, -3 etc In case of error, I need to create log file according to error code. For example code -3 means missing input file use strict; use warnings; use Win32; system ( "$program -f $program.cfg" ); if ($? ==

Re: return code

2005-02-28 Thread John W. Krahn
[EMAIL PROTECTED] wrote: ok so $? states CHILD_ERROR or last status returned by the last ` ` command. $! states yields the current value of errno in shell if I say it will give me a true or false value. cat /tmp/foo if [ $? -eq 0 ] then echo yes command succeeded else echo no. fi In

Re: return code

2005-02-28 Thread DBSMITH
ers PMSubject

Re: return code

2005-02-28 Thread Wiggins d'Anconia
[EMAIL PROTECTED] wrote: $exit_value = $? >> 8 $signal_num = $? & 127; $dumped_core = $? & 128; ok this helps, thanks! But, in my small block of code I am using $? >> 8 as so system ("cat /tmp/used"); # /tmp/used does not exist so this should return 0 for false in Perl and 1 fal

Re: return code

2005-02-28 Thread DBSMITH
cc 02/28/2005 11:38 Perl Beginners AM

Re: return code

2005-02-28 Thread Wiggins d'Anconia
[EMAIL PROTECTED] wrote: It is difficult for me to bottom post as I am using Lnotes. Sorry. See previous rants about this. ok so yes In general, I thought: SHELL 0= true Perl 0 = false SHELL 1 = false Perl 1 = true what do you mean "non zero is false in this context." b/c in general I thoug

Re: return code

2005-02-28 Thread DBSMITH
cc 02/28/2005 10:09 Perl Beginners AMSubject

Re: return code

2005-02-28 Thread Wiggins d'Anconia
Please bottom post... [EMAIL PROTECTED] wrote: ok so $? states CHILD_ERROR or last status returned by the last ` ` command. $! states yields the current value of errno in shell if I say it will give me a true or false value. cat /tmp/foo if [ $? -eq 0 ] then echo yes command succeeded els

Re: return code

2005-02-28 Thread DBSMITH
Perl Beginners 02/27/2005 07:59 cc PM

Re: return code

2005-02-27 Thread John W. Krahn
[EMAIL PROTECTED] wrote: All, am I using the correct method to get the return code whether a previous line or command was 0 false or 1 true? #!/usr/local/bin/perl -w use strict; use strict 'subs'; my $file = qq(/tmp/mbfree); open (F, "+<$file") or die "unable to op

return code

2005-02-27 Thread DBSMITH
All, am I using the correct method to get the return code whether a previous line or command was 0 false or 1 true? thank you, #!/usr/local/bin/perl -w use strict; use strict 'subs'; my $file = qq(/tmp/mbfree); open (F, "+<$file") or die "unable to ope

RE: Getting return code from process launched from exec

2004-04-14 Thread Jason Normandin
D'oh ! Not sure how I missed that. Thanks! That did the trick. -Jason -Original Message- From: Steve Grazzini [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 14, 2004 12:57 PM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: Getting return code from process launched from

Re: Getting return code from process launched from exec

2004-04-14 Thread Steve Grazzini
[EMAIL PROTECTED] wrote: defined (my $pid = fork) or die "Cannot fork process : $!"; unless ($pid){ exec "$Command"; die "Cannot exec : $Command : $!"; waitpid($pid,0); } The waitpid() is unreachable there. Try putting it outside the unless() block, so that the parent will execute

Getting return code from process launched from exec

2004-04-14 Thread jason_normandin
Hi All I need to obtain the return code of a process forked via exec. $? appears to always return 0 even though I know that the actual process had a non-zero return code. Is $? populated to 0 as the exec was sucessfull ? If so, how can I get the return code of the process within the exec call

Re: checking return code

2002-06-05 Thread drieux
On Wednesday, June 5, 2002, at 09:54 , lz wrote: > Hi guys, > > I have the following line: > system("cat $FILENAME | mailx -s \"test\" $mailAddress > "); > > How can I check whether mailx operation above was > successful or not? The homeboys have covered the basic bases but what you will p

Re: checking return code

2002-06-05 Thread David T-G
Leon, et al -- ...and then lz said... % % David, % % Thank you for useful info! Happy to help! % % But as I can see this approach won't catch the problem % if the incorrect email was specified ? Hrmmm... You mean if $mailAddress was incorrectly provided? No, it won't. If mailx exite

Re: checking return code

2002-06-05 Thread lz
or the reason). > ... > > and so a simple > > $rc = system("cat ...") > > (which could, BTW, be written more efficiently > without the cat but > instead with a < to feed mailx) will hold the return > code and you can > then test against that. > &g

RE: checking return code

2002-06-05 Thread Kipp, James
54 PM To: [EMAIL PROTECTED] Subject: checking return code Hi guys, I have the following line: system("cat $FILENAME | mailx -s \"test\" $mailAddress "); How can I check whether mailx operation above was successful or not? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: checking return code

2002-06-05 Thread David T-G
(which could, BTW, be written more efficiently without the cat but instead with a < to feed mailx) will hold the return code and you can then test against that. Our lovely camel book has an example where the divide-by-256 is done for you at capture time that makes this look like $rc = 0x

checking return code

2002-06-05 Thread lz
Hi guys, I have the following line: system("cat $FILENAME | mailx -s \"test\" $mailAddress "); How can I check whether mailx operation above was successful or not? Thank you! __ Do You Yahoo!? Yahoo! - Official partner of 2002 FIFA World Cup htt

Re: return code

2002-01-11 Thread Briac Pilpré
In article <[EMAIL PROTECTED]>, Ahmed Moustafa wrote: > Hi All, > > I'm calling a Java application using "system". How can I know the return > code of the called Java application? perldoc -f system (...) The return value is the exit status of the program as

Re: return code

2002-01-11 Thread Jon Molin
here are two ways: my $exit_code = system ($cmd); system ($cmd); print "exit code = $?\n"; /Jon Ahmed Moustafa wrote: > > Hi All, > > I'm calling a Java application using "system". How can I know the return > code of the called Java application? &g

return code

2002-01-10 Thread Ahmed Moustafa
Hi All, I'm calling a Java application using "system". How can I know the return code of the called Java application? Your help will be appreciated so much. Ahmed -- [EMAIL PROTECTED] | http://www.photo.net/users/ahmed -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additio

Re: Return code to exit from a .bat file

2001-10-01 Thread Mbedish
l which is > > recognised by a .bat file. I have set a return code in the program > > from a subroutine but it is not getting to the operating system. > > You should use 'exit' to return a value from a Perl program back to the > OS. 0 means a normal exit, 1 means

Re: Return code to exit from a .bat file

2001-10-01 Thread Brett W. McCoy
On Mon, 1 Oct 2001 [EMAIL PROTECTED] wrote: > I think my main problem is getting an eror out of perl which is > recognised by a .bat file. I have set a return code in the program > from a subroutine but it is not getting to the operating system. You should use 'exit' to re

Re: Return code to exit from a .bat file

2001-10-01 Thread Mbedish
I think my main problem is getting an eror out of perl which is recognised by a .bat file. I have set a return code in the program from a subroutine but it is not getting to the operating system. __SNIP__ while () { chomp; $length = length($_); if ($length != $lp) { print

Re: Return code to exit from a .bat file

2001-10-01 Thread Rajeev Rumale
echo " Stopped for error." For more info check this site http://www.computerhope.com/batch.htm Regareds Rajeev - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, October 01, 2001 5:56 PM Subject: Return code to exit from a .ba

Return code to exit from a .bat file

2001-10-01 Thread Mbedish
I am doing a simple record length check on a series of files via a dos batch file e.g. check_length.bat: check_length.pl file1 100 check_length.pl file2 200 check_length.pl file3 300 Is it possible to do something in perl (like a return code) so that the batch file aborts if say file2 is