[Boston.pm] taking in info from command-line command

2005-07-05 Thread Alex Brelsfoard
OK, so I know there's an easy-ish way to handle this situation.  But I'm
currently running in circles, not finding the solution.  Basically what I'm
trying to do is run a system command (with either `command` or
system(commnad) ) and retrieve the printed result form the command into a
variable of some sort.
So think of it this way:
my $info = `ls`;

or for Windows users:
my $info = `dir`;

If I run this from the command line it will print the results (because the
command was run), but the output is NOT put into $info.

I don't care what kind of variable (scalar, array, etc.) this information is
stored in, but all the ways I've been trying are NOT working.
I guess it's important to know that this will in the end be used in a web app.

Thanks for any help.
--Alex
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] taking in info from command-line command

2005-07-05 Thread Tim Wilde
On Tue, 5 Jul 2005, Alex Brelsfoard wrote:

 OK, so I know there's an easy-ish way to handle this situation.  But I'm
 currently running in circles, not finding the solution.  Basically what I'm
 trying to do is run a system command (with either `command` or
 system(commnad) ) and retrieve the printed result form the command into a
 variable of some sort.
 So think of it this way:
 my $info = `ls`;

And this doesn't work?  Is your command outputting on STDOUT or STDERR? If it's 
dumping its output on STDERR, try adding 21 to the end of your command in 
back-ticks, that will redirect STDERR to STDOUT, and might get the output 
captured properly (though I haven't tried it).

Tim Wilde

-- 
Tim Wilde
[EMAIL PROTECTED]
Systems Administrator
Dynamic Network Services, Inc.
http://www.dyndns.com/
 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm


Re: [Boston.pm] taking in info from command-line command

2005-07-05 Thread alexb
Thanks Tim,

 Though this was not the solution to my problem, I beleive that it 
helped me
find that solution.  I needed to specify the full path of the command I was
trying.  Since I was not specifying the full path I was getting an error
message.  After adding that code snippet I was informed of this  :)

Thanks for the help.
--Alex

Quoting Tim Wilde [EMAIL PROTECTED]:

 On Tue, 5 Jul 2005, Alex Brelsfoard wrote:

 OK, so I know there's an easy-ish way to handle this situation.  But I'm
 currently running in circles, not finding the solution.  Basically what I'm
 trying to do is run a system command (with either `command` or
 system(commnad) ) and retrieve the printed result form the command into a
 variable of some sort.
 So think of it this way:
 my $info = `ls`;

 And this doesn't work?  Is your command outputting on STDOUT or STDERR?
 If it's dumping its output on STDERR, try adding 21 to the end of your
 command in back-ticks, that will redirect STDERR to STDOUT, and might get
 the output captured properly (though I haven't tried it).

 Tim Wilde

 -- Tim Wilde
 [EMAIL PROTECTED]
 Systems Administrator
 Dynamic Network Services, Inc.
 http://www.dyndns.com/




 
___
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm