Re: Execute Windows program from Perl script (??)

From: kevincar (kevindotcar_at_yahoo.com)
Date: 09/08/04


Date: 7 Sep 2004 15:39:38 -0700

tony@paradoxcommunity.com (Tony McGuire) wrote in message news:<f896a829.0408290616.31b184ef@posting.google.com>...
> Well, I'm going to take the easy way out.
>
> I'll just write something to a file with perl, and have the scheduler
> watch for that file to be modified.
>
> Then the scheduler program can start the external program.
>
> Thank you to everyone who participated. I really do appreciate the
> feedback, regardless of whether it helped or not.

Hi all,
 Lucky me, I just ran into this problem this morning, so I thought
 I'd chime in on how I got mine to work ... It's really more of
 an Apache config question, but what the hey; Perl is the most used
 CGI program anyway (AFAIK).

My Simple problem description; I have a VB program that I wanted
a user to be able to run on my Apache/Perl equipped server -
I tried this originally with a 1-liner Perl CGI script;
  
  #!c:/Perl/perl.exe -w
  system("m:/bah/blah/vbrunprogram.exe");

...obviously, it was installed under cgi-bin and it was a
UNIX-style ascii file and all that stuff - It worked when I
called it from a command window but my Apache logs always
said "Access Denied" when called from a brower.

There were two things going on;
First, it was a file on a networked drive and apache didn't
know the first thing about what to do with it-

Second; Apache doesn't use your logon account; It *could*, but
it DEFINITELY is not very adviseable!!!

I solved the problem by having the cgi "1-liner" script call
a DOS bat file with a "net use" wrapper around it;

C:\cat script.bat
NET USE M: \\machine\mtpoint
m:/bah/blah/vbrunprogram.exe
NET USE M: /DELETE

...and change the script to call the bat file;
#!c:/Perl/perl.exe -w
system("script.bat");

Be warned; the "system" call will dump everything from the
BAT file onto the user's brower- don't put any embarassing
comments in it!

Hope this helps,
K.c



Relevant Pages