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:[email protected]
--------------------------------------------- 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
Oeschey, Lars (I/ET-83, extern)
Sent: 30 October 2009 13:38
To: [email protected]
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
[email protected]
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 intended recipient. The content of this e-mail and 
any file or attachment transmitted with it may have been changed or altered 
without the consent of the author. If you are not the intended recipient, 
please note that any review, dissemination, disclosure, alteration, printing, 
circulation 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 with it are unencrypted unless specifically 
advised otherwise. If you have received this e-mail or any file or attachment 
transmitted with it in error please notify Anglo Irish Bank Corporation 
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 Bank Corporation Limited (trading as Anglo Irish Bank Private 
Banking) is regulated by the Financial Regulator. Anglo Irish Assurance Company 
Limited is regulated by the Financial Regulator. 
**********************************************************************

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to