Okay forgive me if I have bad formatting as it's only my second post...
What I'm trying to do:
When I click a link, I want it to run a batch file to install a program on a server, and return a result upon installation failure or success.
The Problem:
I first wrote this script to be executed through the command line, so when I had to make some changes to make it work through a web browser. The batch file takes about five minutes to complete, so I had to prevent the browser to time out.
Here's my code:
#!perl -w
use CGI;
$c = new CGI();
print $c->header();
$| = 1;
### set up an alarm
$timeout = 7*60; # apache normally times out after 5 min
print "<!--\n"; # hide output
$SIG{ALRM} = sub{ print ".\n"; alarm($timeout); };
# the timeout will send something to the browser every
# now and then to keep it from timing out
alarm($timeout);
print "Installing Dell Open Manage";
&install_open_manage();
alarm(0);
print "-->\n"; # don't need to hide output anymore
print $result;
<---- do other stuff here ---->
exit();
sub install_open_manage {
$host = "hostA";
print "\n$count: Checking for local RAC configuration.<br>";
sleep(1);
$result = `psexec \\\\$host -u location\\admin -p password \\\
+\host01\\OpenManage\\setup_sibar.bat 2>&1`;
return $result;
}
The script runs, and the program is installed, but the results and the stuff after it is not printed.
***EDIT
Still no luck. I added
start before the psexec and redirected the output to a text file, however nothing gets written to the file. One thing i noticed is that if I do something other than an install in the install_open_manage subroutine (such as a sleep(100) and a 'dir' command) my script works fine.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.