amoura has asked for the wisdom of the Perl Monks concerning the following question:

Hello guys , I want to direct the output from the following to a file
system qw(update blablblbabal);
I tried this
chdir "x:"; system qw(update blablblbabal)> $temp/out.txt;
also this
chdir "x:"; system "update blablblbabal)> $temp/out.txt";
but no luck , in the second one the update don't like >out.txt . ps . the $temp is my current drive not x drive ... any ideas .. thanks

edited: Tue Jul 9 04:47:48 2002 by jeffa - added code tags

Replies are listed 'Best First'.
Re: direct output from System command
by chromatic (Archbishop) on Jul 08, 2002 at 19:50 UTC
Re: direct output from System command
by robobunny (Friar) on Jul 08, 2002 at 20:02 UTC
    this should do what you want (you should supply better error messages, obviously). i don't know how output redirection works in windows, but this is probably more portable anyhow.
    open(B, "update blablblabl |") or die "noo! $!"; open(O, ">$temp/out.txt") or die "why me! $!"; while(<B>) { print O; } close(B); close(O);
Re: direct output from System command
by greenFox (Vicar) on Jul 09, 2002 at 01:33 UTC
    If you want to stuff the output of <command> into a file without seeing it in your program you can also do this-
    system("command > $temp/out.txt");

    You cannot use this method with multiple arguments to system() ie. system("command", "arg1", "arg2", ">file"); doesn't work.

    --
    my $chainsaw = 'Perl';