Re: Run an external program and capture its output

[email protected] (John Emmas) Thu, 17 Apr 2014 09:32:12 +0100
Newsgroups perl.win32.vanilla
Message-ID <[email protected]>
On 17/04/2014 08:36, kmx wrote:
> FWIW, the
>>
>> my $output = `the_exe_name arg1 arg2`;
>>
>> way is to capture just STDOUT - _not_ STDERR. Regardless of OS.
>>
>>
>

Many thanks.  As it happens, I'm only interested in capturing stdout.  I 
tried 3 x variations, based on your suggestions:-

Attempt #1:
         my $output = 'gtk-update-icon-cache --force 
--ignore-theme-index --source builtin_icons gtk/stock-icons';

Response a) - simply running 'my_perl-script.pl' produces no output file.
Response b) - running 'my_perl_script.pl > test.txt' produces an output 
file called "test.txt" but it's still empty.

Attempt #2:
         use IPC::Run3;
         my $output;
         run3(["gtk-update-icon-cache", "--force", 
"--ignore-theme-index", "--source", "builtin_icons", "gtk/stock-icons"], 
undef, \$output);

Response a) - simply running 'my_perl-script.pl' produces no output file.
Response b) - running 'my_perl_script.pl > test.txt' produces this error 
message:-
         run3(): Permission denied saving STDOUT at 
F:\GTK-SOURCES\my_per_script.pl line 6.

Attempt #3:
         use IPC::Run3;
         my $output;
         run3(["gtk-update-icon-cache", "--force", 
"--ignore-theme-index", "--source", "builtin_icons", "gtk/stock-icons"], 
undef, \$std_out);

Responses are identical to attempt #2

It seems so near and yet so far away!

John