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
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:
>
>
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
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
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
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
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
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) {
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 ($? ==
[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
ers
PMSubject
[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
cc
02/28/2005 11:38 Perl Beginners
AM
[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
cc
02/28/2005 10:09 Perl Beginners
AMSubject
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
Perl Beginners
02/27/2005 07:59 cc
PM
[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
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
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
[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
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
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
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
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
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]
(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
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
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
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
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
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
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
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
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
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
36 matches
Mail list logo