The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Perl Programming
|
How run file.bat with script.cgi on server side
Discuss How run file.bat with script.cgi on server side in the Perl Programming forum on Dev Shed. How run file.bat with script.cgi on server side Perl Programming forum discussing coding in Perl, utilizing Perl modules, and other Perl-related topics. Perl, the Practical Extraction and Reporting Language, is the choice for many for parsing textual information.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

February 19th, 2013, 08:51 AM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 3
Time spent in forums: 1 h 51 m 23 sec
Reputation Power: 0
|
|
|
How run file.bat with script.cgi on server side
Hi all, i need a script.cgi to run a file.bat from my webpage on the server side.
Plees Help
Thank's
|

February 19th, 2013, 09:46 AM
|
|
|
|
What have you tried?
What errors/warnings are you receiving?
|

February 20th, 2013, 04:53 AM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 3
Time spent in forums: 1 h 51 m 23 sec
Reputation Power: 0
|
|
Hi, i use this script but not work  , this script is called from my webpage
#!c:\mrtg\perl\bin\perl.exe -w
use CGI;
$parse = new CGI;
print $parse->header;
$rc=`C:\\xxx\\xxxxx.bat`;
print "$rc\n";
|

February 20th, 2013, 06:22 AM
|
 |
'fie' on me, allege-dly
|
|
Join Date: Mar 2003
Location: in da kitchen ...
|
|
The file will need to be in a webserver accessible directory ...
perl Code:
Original
- perl Code |
|
|
|
$rc=`C:\\xxx\\xxxxx.bat` or die $!;
__________________
--Ax
without exception, there is no rule ...
Handmade Irish Jewellery
Targeted Advertising Cookie Optout (TACO) extension for Firefox
The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones
 
09 F9 11 02
9D 74 E3 5B
D8 41 56 C5
63 56 88 C0
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. -- Jamie Zawinski
Deta vil - the devil is in the detail, allegedly, and I use the term advisedly, allegedly ... oh, no, wait I did ...
BIT COINS ANYONE
|

February 20th, 2013, 08:14 AM
|
|
Registered User
|
|
Join Date: Feb 2013
Posts: 3
Time spent in forums: 1 h 51 m 23 sec
Reputation Power: 0
|
|
|
I tried , xxxx.bat is not runned on server side, and is displaied in my webpage the patch to xxxx.bat
|

February 20th, 2013, 08:50 AM
|
|
|
Use forward slashes in the path instead of the back slashes.
A var name of $rc implies that you want the return code of the command, not its output. So, are you expecting $rc to contain the return code of the bat file or the output that it generates?
EVERY Perl script you write should include the strict and warnings pragmas. Those pragmas will point out lots common mistakes.
While developing cgi scripts, you should add the CGI::Carp module and remove it when the script goes into production.
$parse is not a very good var name for the cgi object. Var names should give an indication of what they hold and/or what they are used for.
It's best practice to not use the indirect object notation (i.e., syntax you used when creating the $parse object).
What happens when you run the bat file from the command line?
Does the user account that the web server is running under have proper permissions to run the bat file?
Add a little vertical and horizontal whitespace to add readability.
Code:
#!c:\mrtg\perl\bin\perl.exe
use strict;
use warnings FATAL => 'all';
use CGI;
use CGI::Carp qw(fatalsToBrowser);
my $cgi = CGI->new;
print $cgi->header;
my $cmd = 'C:/path/to/some.bat';
my $cmd_output = `cmd`;
print $cgi->p($cmd_output);
print $cgi->end_html;
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|