toastbread has asked for the wisdom of the Perl Monks concerning the following question:
Hi I have a concern regarding executing a child process and get its output. My program uses perl Tk and my assigned task is to removed any appearing DOS Window when using my application. It should just shows Tk's GUI.
I have succesfully removed the DOS windows when starting the program and executing some applications using Win32::Process.
But this time, I need to execute a process and get its output. It seems that Win32::Process dont have function to get the output of a child process.
To be specific I am trying to run the following commandline and save its output to a buffer or file:
findstr /r /c:"$string" /f:"$file_list"
"findstr" command usually prints its output to STDOUT but I need to removed the DOS window. Is there a way of running a child process and redirect its output to variable or file without showing the DOS window?
I have used system(), open(FH,"commanline |"), exec(), and backticks but they are all showing the DOS window. When using Win32::Process it succesfully don't show the DOS Window but I cannot get the output of the child process.
I haven't try running cmd.exe itself using Win32::Process and use option to hide its window which I guest will work. But:
-"cmd /c" has limitation when using double quote(") and will not work to all double quote contained command lines.
-i don't know the perl function to get path of cmd.exe since using "set comspec" also shows its output in DOS Window.
I hope there's a feature in perl to solve my problem.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: In Perl Tk: Run a commandline and get its output without showing the DOS Window
by BrowserUk (Patriarch) on Jan 11, 2010 at 13:36 UTC | |
by toastbread (Novice) on Jan 11, 2010 at 13:57 UTC | |
|
Re: In Perl Tk: Run a commandline and get its output without showing the DOS Window
by cdarke (Prior) on Jan 11, 2010 at 14:20 UTC |