Forward Design wrote:

> I have Windows 2000, latest Apache installed for Windows, and latest 
> Active Perl installed.
> 

Please read my Apache mini-FAQ on my Tripod site (address in .sig).

> 
> I am very new to this, but this is what I can already do and have working:
> 
>  
> 
> I can access a webpage that I placed in the htdocs folder from my IP 
> address.
> 
>  
> 
> I can run a simple perl script.
> 
>  
> 
> Here is what I want to do:
> 
>  
> 
> I want to have a webpage, when a user clicks on a button, it runs a perl 
> script
> 
>  
> 
> on my server (my machine), that then runs a Windows program on the 
> server, which
> 
>  
> 
> spits out a file, that the user can then download.
> 
>  
> 
> No, I am not trying for the user to see the GUI of the windows program.
> 
>  
> 
> The windows program, will eventually have no interface, just run, do its 
> work, and exit.
> 
>  
> 
> My problem is this, I have an HTML page with a button, that calls my 
> perl script.
> 
>  
> 
> The perl script is using the command:
> 
>  
> 
> system('d:\myprog.exe');


Try using the built-in 'unlink' function instead.



> When that command is executed, my machine just sits there.
> 
>  
> 
> I see that 'myprog.exe' is listed in the Task Manager, but I cannot end 
> that process, permission denied.
> 
>  
> 
> I can type into a dos window 'perl myperlscript.pl', which contains the 
> system
> 
>  
> 
> command above, and sure enough, my program pops up (right now, the windows
> 
>  
> 
> program does have a GUI).
> 
>  
> 
> The GUI is not a problem, I have tried this, and others, something 
> simple, and it still hangs:
> 
>  
> 
> system('delete d:\crap.txt');
> 
>  
> 
> The Apache error logs never gets filled in, because the script never 
> stops, it hangs.
> 
>  
> 
> What am I doing wrong?
> 
>  
> 
> I know this must be a stupid problem/answer, but I need help.
> 
>  
> 
> How does one have a perl script, called from an HTML page, run a windows 
> exe?


One normally avoids this sort of thing.  If you really must, try more 

like this (untested in this form):

                my $shell = 'C:\\windows\\command.com /C';
                my @systemargs = ($shell, 'delete', 'd:\crap.txt');
                my $ret = system (@systemargs);

delete is part of your shell functionality (use cmd.exe vs command.com if
not on 9x).

Sample download script:

use strict;

my $path = 'c:/rootdir';                # example path to download files
my $file = 'image.gif';                 # example (or get from args)
my $mimetype = 'image/gif';             # example (or create hash for .ext)
my $size = -s "$path/$file";            # get file size
$size or die "$path/$file: empty file";

open IN, "$path/$file" or die "$path/$file download: $!";
binmode IN;                             # needed on Win32 for binary files

# these headers in one combination or another should handle the popup getting
# the right filename on the download (instead of script name)

print <<EOD;
Content-type: $mimetype; name="$file"
Content-disposition: attachment; filename=$file
Content-length: $size

EOD
# I'm told no quotes around $file on Content-Disposition header for MSIE ??

binmode STDOUT;                         # needed on Win32 for binary files
#print <IN>;                            # this would be fine for text vs sysread/write

# using block read/write instead of above print (better for binary data)

while (sysread (IN, my $buf, 4096)) {   # 4096 is arbitrary choice for blksize
        syswrite STDOUT, $buf, length $buf;
}

close IN;

__END__


-- 
   ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
  (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/

_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to