Use backticks...

my $output = `dir c:\\`;

Rob

-----Original Message-----
From: Mike Garner [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 14, 2002 12:36 PM
To: [EMAIL PROTECTED]
Subject: Getting System Output in Variable


How do you get the output of a system command into a variable without 
piping to a temporary text file that I would later have to open and process?
Ex on win32:
system("dir c:\\ >dir.txt"); #pipe the directory listing to dir.txt
$var = system("dir c:\\ >dir.txt"); #only returns numerical codes for $var 
not necessarily the true output
system("dir c:\\ >$var"); #Basically the idea I am looking for but this 
doesn't work as the syntax of the system command is incorrect.

I'm curious about the process. I don't need it for the 'dir' command 
specifically but any system command that returns some output.

Thanks alot!
-Mike



--------------------------------------------------------------
Mike Garner
Western State College
Email: [EMAIL PROTECTED]
Voice: 970-943-3123
Fax: 970-943-7069


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to