shell - Perl as a batch-script tool - fully piping child processes? -


apologies if of terminology may slighlty off here. feel free correct me if use wrong term something.

is possible use perl "advanced shell" running "batch" scripts? (on windows)

the problem face when replacing .bat/.cmd script that's getting complicated perl script can't run sub processes shell does.

that is, same thing perl script shell when invoking child process, is, "connecting" stdin, stdout , stderr.

example:

foo.bat -

@echo off echo hello, simple script. set param_x=really-simple  :: next line allow me "use" tool on shell have open,  :: stdout + stderr of tool displayed on stdout + stderr , if :: enter on keyboard sent tools stdin  interactive_commandline_tool.exe %param_x%  echo tool returned %errolevel% 

however, have no clue how fully implement in perl (is possible @ all?):

foo.pl -

print "hello, not simple script.\n"; $param_x = get_more_complicated_parameter();  # magic: sub executes process , hooks stdin/out/err ,  # returns process error code when done $errlvl = run_executable("interactive_commandline_tool.exe", $param_x); print "the tool returned $errlvl\n"; 

how can achieve in perl? played around ipc::open3 seems doesn't trick ...

why not way:

print "hello, not simple script.\n"; $param_x = get_more_complicated_parameter();  system('cmd.exe', $param_x); $errorlevel = $? >> 8; print "the tool returned $errorlevel\n";  sub get_more_complicated_parameter { 42 } 

i don't have interactive program, shell executed allowed me enter commands, has inherited environment defined in perl, etc.

i using perl replacement more complicated shell scripts on windows long time , far needed possible.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -