Re: Problem getting command output
- From: "John W. Krahn" <krahnj@xxxxxxxxx>
- Date: Mon, 29 Oct 2007 19:50:09 GMT
TonyV wrote:
I'm running ActiveState Perl version v5.6.1 built for MSWin32-x86-
multi-thread.
I have a script that is being run from another application (HP
Openview Operations for Windows) under the NT Authority\SYSTEM
account, and when I try to collect the output of a command using
something like this:
my $output = `defrag -a c:`;
It comes back blank. It doesn't matter which command I try to run, it
always comes back blank. I really need the output of the command. If
I redirect it to a file like so:
`defrag -a c: > c:\\test.txt`;
It puts the correct info into the file.
I'm not sure why the output is being suppressed. I checked that STDIN
and STDOUT exists using the if (-t STDIN && -t STDOUT), and they both
seem to be.
Does anyone know if there's something special I need to do when trying
to read the output of system commands when scripts are run from within
an automated service-type application? I'm trying to avoid echoing
the results to a file and reading the file in if possible.
Try running it like this:
open PIPE, "defrag -a c: |" or die "Cannot open pipe from defrag: $^E":
my $output = do { local $/; <PIPE> };
close PIPE or warn $! ? "Error closing de*** pipe: $!"
: "Exit status $? from defrag";
Then you may get some indication that there may be something wrong.
(Disclamer: I don't do Windows. YMMV)
John
--
use Perl;
program
fulfillment
.
- References:
- Problem getting command output
- From: TonyV
- Problem getting command output
- Prev by Date: Re: Query returns -1 if row present (DBI, SQL Server 2000)
- Next by Date: Re: Query returns -1 if row present (DBI, SQL Server 2000)
- Previous by thread: Problem getting command output
- Next by thread: Problem getting command output
- Index(es):