http://www.perlmonks.org?node_id=990109


in reply to Re: Win32::Process::Create fails when i use ">" to redirect the screen output to a file
in thread Win32::Process::Create fails when i use ">" to redirect the screen output to a file

I am open to correction, but I believe that > would not be a part of the command line passed to notepad, but rather would be passed to your shell (cmd.exe, cygwin's sh, whatever).

Also I don't think that notepad.exe actually outputs anything to the console under usual circumstances, being a completely GUI application.

I do not believe cmd.exe supports 2>&1 style redirects (apparently it does, see here, thanks for the headsup), so you would have to be using cygwin's sh or perhaps SUA perl. In that case, why aren't you just using system, qx or open?
  • Comment on Re^2: Win32::Process::Create fails when i use ">" to redirect the screen output to a file
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: Win32::Process::Create fails when i use ">" to redirect the screen output to a file
by syphilis (Archbishop) on Aug 28, 2012 at 03:04 UTC
    Hi,
    Just a minor correction - cmd.exe *does* support 2>&1 (and the like) redirection.

    Cheers,
    Rob
Re^3: Win32::Process::Create fails when i use ">" to redirect the screen output to a file
by prayaspatel (Initiate) on Aug 28, 2012 at 17:59 UTC
    i am using tool.exe but i just mentioned notepad.exe to give as an example. sorry about that. when i only put tool.exe without putting "> log.txt 2>&1" in Win32::Process::Create() it works fine.

    Also, i can run "tool.exe > log.txt 2>&1" directly from commandline but when i try to use it using Win32::Process::Create() its giving those errors that i mentioned in my initial question.