Click here to Skip to main content
15,868,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I am trying to store the command prompt output in to the veriable.
I am running some commands on command prompt which gives output in single value as well as in multiple values. I want to store those values into the array variable. But I dont know how to fetch the command prompt output.

Could anybody have an idea how to do it?
I am googling on it but didnt get any usefull solution yet.
Posted

The simple way is to use backticks:
PERL
$list = `ls -al`;


- that will give you the command output in one variable. If you want it split into an array of lines:
PERL
@list = split $/, `ls -alh`;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900