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

Can somebody help me out with this .....
I am facing problems while redirecting the output of a System command on Windows 98.
The following code works perfectly fine on Linux and Windows 2000, but gives a error "Bad command or file name" on my Windows 98 machine ...
My command : system("perl engine.pl rep\\sample.txt > rep\\sample_done.txt");
It always gives an error when it encounter's the symbol ">"
It's very urgent !!!!!
Thanks in Advance,
Danny

Replies are listed 'Best First'.
Re: Redirecting System command output !!
by theorbtwo (Prior) on Aug 03, 2002 at 08:33 UTC

    I suspect the problem is that win(95|98|ME) use command.com, whereas win(NT|XP) use cmd.exe, which has better support for many things. Try placing a copy on the win98 box, and chaning $ENV{PERL5SHELL} to get perl to use it instead. (And read perldoc perlwin32. I'd link to it, but for some reason, perldoc.com's copy it empty.)


    Confession: It does an Immortal Body good.

Re: Redirecting System command output !!
by Courage (Parson) on Aug 03, 2002 at 09:38 UTC
    Actually this is because shell does not knows where to find perl, or it is not installed. Is per.exe exists on your PATH variable? what do you see when you enter perl -v from console window?

    Courage, the Cowardly Dog.

Re: Redirecting System command output !!
by zaimoni (Beadle) on Aug 03, 2002 at 20:43 UTC

    You're using double-quoted strings. BAD move on a Win__ system when calling the system command. I don't want to guess how the autoescaping is going to interact, here.

    Also make sure that the perl executable is perl.exe, and that its directory is on your PATH.

    Try:

    system('perl engine.pl rep\sample.txt rep\sample_done.txt')

    or

    system('perl engine.pl rep/sample.txt rep/sample_done.txt')

    The latter relies on Perl's interpolation of POSIX directory separators regardless of OS.

Re: Redirecting System command output !!
by belg4mit (Prior) on Aug 04, 2002 at 05:56 UTC
    Why are you even bothering with system? If you want to capture the output you are almost certainly better off using qx, especially considering the return values on Win32 are probably less than useful.

    --
    perl -pew "s/\b;([mnst])/'$1/g"