in reply to How do I execute a bat file from cgi script?

Do read the above links, they are good. Do you want to wait for that .bat file to finish before your script continues, or do you want the script to carry on once it starts the .bat. If the latter, what should happen if the script finishes before the .bat it launched? Here is some totally untested code to give you some ideas

use strict; # Always start a Perl script with these two without the +m use warnings; # there are many subtle ways to shoot yourself in the f +oot use CGI; # Load the module to handle CGI stuff my $cgi = CGI->new(); # get a CGI object. # Point to the batfile, notice we can use / as a path separator in Per +l # even when we are in a Windows world. my $batfile = 'c:/program files/mycode/batman.bat'; # I guess you are going to get the parameter from the CGI invocation my $param = $cgi->param('some_field'); # run the command and wait for it to complete. Catch STDERR my $result = `$batfile $param 2>&1`; # This probably won't work as we did not set up an http header, you ma +y want # to use logfile, send output to the cgi invoker, or just throw it aw +ay Print "the command: $batfile $param\nGasve the result: $result";

This code will be saved in your cgi-bin and invoked with a url like:

http://yourserver/cgi-bin/thiscode.pl?some_field=fieldOfDreams

Cheers,
R.

Pereant, qui ante nos nostra dixerunt!

Replies are listed 'Best First'.
Re^2: How do I execute a bat file from cgi script?
by btpoole (Initiate) on Dec 09, 2013 at 15:54 UTC

    Thank you all for the direction. I have read the majority of the links and started to get an idea. The bat file will continue to run after the script ends. The bat file will end when the current channel is exited. Other than starting the bat file, the script will really do nothing else. The script will be called from code on the roku, once the script starts the bat file, the roku executes it's next line which is to start streaming the file created by the bat file. Thanks again