Assigning Output of a Command to an Array in Perl
Hi,
I am trying to execute a Unix Command in perl and assigning its output to an array: Code:
@File_List=exec("ls -1 /tmp"); In fact, the output is still being generated and displayed but not being assigned to the array. Any ideas? |
Quote:
Secondly, you do not need this in the first place - read http://perldoc.perl.org/functions/opendir.html http://perldoc.perl.org/functions/readdir.html http://perldoc.perl.org/functions/closedir.html . |
|
Quote:
Now, consider these two lines of perl statements: this: Code:
exec("ifconfig eth0"); Code:
$ip=exec("ifconfig eth0"); In fact, I want to store the result of a Shell Script,which I can run using the exec() function, in a variable or an array. |
Code:
@File_List=`ls -1 /tmp`; |
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
|
Quote:
Your code should not work exactly because of the very first sentence of 'exec' description: http://perldoc.perl.org/functions/exec.html : Code:
The exec function executes a system command and never returns By the way, you are not only willfully illiterate, you are also ignoring an answer given to you in very first reply posted by me. Namely (see items in Red in Code section below, scroll right for that): http://www.linuxquestions.org/questi...4/#post4171251 -> http://perldoc.perl.org/perlop.html#...Like-Operators -> Code:
Quote-Like Operators Quote:
|
All times are GMT -5. The time now is 12:39 PM. |