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

Help please I have a cgi script that creates an ms-dos batch file and displays it in the browser window
rename c:\1\kjlkug.csv file1.csv move c:\file1.csv d:\now\ rename c:\1\123123.jpg file1a.jpg move c:\file1a.jpg d:\now\ rename c:\1\123124.jpg file1b.jpg move c:\file1b.jpg d:\now\
my script then creates a text document called cars.bat then I have to: copy the contents of the browser window,open the cars.bat file for editing, paste the copied data, run the batch file then delete it What I would like to know : is it possible to create and then execute ms-dos batch files straight from cgi? If so, a clue would be nice, many thanks

Replies are listed 'Best First'.
Re: create and run
by marto (Cardinal) on Jan 13, 2006 at 11:13 UTC
    Hi Cockneyphil,

    Could you not use something like File::Copy within your code to do your file copying rather than creating then running a batch file? You may want to look at perldoc system.

    Martin
Re: create and run
by Fletch (Bishop) on Jan 13, 2006 at 13:57 UTC

    You want your browser to execute an arbitrary batch file sent to you from a remote source? Not exactly the best of ideas . . .

    format /y C:

    If you're really determined you probably could set up a special content type (say application/x-WTF-THIS-IS-DANGEROUS) and have your browser set to open that with cmd or command or what not.

Re: create and run
by john_oshea (Priest) on Jan 13, 2006 at 11:24 UTC

    I'm a little unclear - are you running the batch file on the same machine that creates it?