RE: system/backticks output not as expected
by Conor Lillis other posts by this author
Oct 30 2009 6:49AM messages near this date
Re: system/backticks output not as expected
|
Help with $_
I usually capture the output for backticks to an array rather than a
string so try
my @return=`$command`;
Foreach my $line(@output){print "$line\n"}
Regards,
Conor Lillis
---------------------------------------------
Senior Systems Administrator,
Group Network Services,
Phone +353-1-616-2540
Anglo Irish Bank
www.angloirishbank.ie
mailto:conorlillis@[...].ie
---------------------------------------------
-----Original Message-----
From: activeperl-bounces@[...].com
[mailto:activeperl-bounces@[...].com] On Behalf Of
Oeschey, Lars (I/ET-83, extern)
Sent: 30 October 2009 13:38
To: activeperl@[...].com
Subject: system/backticks output not as expected
Hi,
I have a problem getting the output of a system call. It's a simple
code:
my $return=`$command`;
print "$?\n";
print "result:$return\n";
(I am calling a command which actually doesn't exist, to check error
handling)
as result on the console I have:
Das System kann das angegebene Laufwerk nicht finden.
256
result:
The first error says it can't find the program. Actually I expected this
in $return.
compared to system():
my $return=system("$command");
print "$?\n";
print "result:$return\n";
Das System kann das angegebene Laufwerk nicht finden.
256
result:256
So obviously system() returns the error code. But why don't the
backticks return anything at all? Ideally I'd want all the output
catched to log, but still be able to react on errors...
Lars
_______________________________________________
ActivePerl mailing list
ActivePerl@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
**********************************************************************
Private, Confidential and Privileged. This e-mail and any files and attachments transmitted
with it are confidential and/or privileged. They are intended solely for the use of the inte
nded recipient. The content of this e-mail and any file or attachment transmitted with it ma
y have been changed or altered without the consent of the author. If you are not the intende
d recipient, please note that any review, dissemination, disclosure, alteration, printing, c
irculation or transmission of this e-mail and/or any file or attachment transmitted with it,
is prohibited and may be unlawful. This e-mail and any files and attachments transmitted wi
th it are unencrypted unless specifically advised otherwise. If you have received this e-mai
l or any file or attachment transmitted with it in error please notify Anglo Irish Bank Corp
oration Limited, Stephen Court, 18/21 St Stephen's Green, Dublin 2, Ireland, telephone no: +
353-1-6162000.
Directors: D.M. O'Connor Chairman, A.M.R. Aynsley (Australian) Chief Executive, F.M. Daly,
A.M. Dukes, M.A. Keane.
Registered Office: Stephen Court, 18/21 St Stephen's Green, Dublin 2 Ireland
Registered in Ireland: No 22045
Anglo Irish Bank Corporation Limited is regulated by the Financial Regulator. Anglo Irish Ba
nk Corporation Limited (trading as Anglo Irish Bank Private Banking) is regulated by the Fin
ancial Regulator. Anglo Irish Assurance Company Limited is regulated by the Financial Regula
tor.
**********************************************************************
_______________________________________________
ActivePerl mailing list
ActivePerl@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Lars Oeschey
Brian Raven
Serguei Trouchelle
Conor Lillis
|