S
Scott Clay
This is as simple as I can write this for now. My program is a lot more
complicated using telnet objects and logging into a server and collecting
logs from it.
I've broken it down into this.
I have a simple form on a solaris web server. I'm trying to control the
program with 2 buttons. A start & stop button. On clicking the start button,
I enter an infinite while loop. I can kick out of the loop if a global
variable is set to stop when clicking on the stop button. However, I 'm
finding out that the start button is actually kicking off it's on process on
the machine. Upon clicking the stop button, this process remains.
zrc2s0ry-261> ps -ef | grep tricky
mtxweb 11896 16920 0 14:47:40 pts/20 0:00 vi tricky2.cgi
mtxweb 28303 6556 0 15:04:12 pts/4 0:00 grep tricky
mtxweb 28291 11896 2 15:04:04 pts/20 0:01 /usr/bin/perl tricky2.cgi
I've browsed the ipc perldoc, but not quit sure I really understand what is
going on. What methodology do I need to use, to have the 2nd instance of the
cgi script pass the global variable in which I'm trying to control the
program to the 1st instance?
Here is the sample. Just starting counting by 1, and print the value,
forever. When the stop button is clicked, I want the first process to finish
by exiting the while loop and return control to the user.
#!/usr/bin/perl
use CGI;
$query = new CGI;
$done4 = 'Stop';
print $query->header;
print $query->start_html("Counter");
print "<h1>IPC</h1>\n";
&print_prompt($query);
&do_work($query);
&display_count();
print $query->end_html;
#########################
sub print_prompt
#########################
{
my($query) = @_;
print $query->start_form;
print "<p>counting by 1s<br>";
print "<br>";
print $query->submit('Action', 'Start');
print $query->submit('Action', 'Stop');
print "<br>";
print $query->endform;
print "<hr>";
}
#########################
sub do_work
#########################
{
my($query) = @_;
my(@values,$key);
print "<h3>Settings</h3>";
foreach $key ($query->param) {
print "<strong>$key</strong> -> ";
if ($key eq 'Action') {
$done4 = $query->param($key);
}
@values = $query->param($key);
print join(", ",@values),"<br>\n";
}
}
#########################
sub display_count
#########################
{
$i = 1;
print "DONE: ", $done4;
print "<br>";
while (1) {
last if ($done4 eq 'Stop');
print "I= ", $i++;
print "<br>";
}
}
Thanks,
Scott
(e-mail address removed)
complicated using telnet objects and logging into a server and collecting
logs from it.
I've broken it down into this.
I have a simple form on a solaris web server. I'm trying to control the
program with 2 buttons. A start & stop button. On clicking the start button,
I enter an infinite while loop. I can kick out of the loop if a global
variable is set to stop when clicking on the stop button. However, I 'm
finding out that the start button is actually kicking off it's on process on
the machine. Upon clicking the stop button, this process remains.
zrc2s0ry-261> ps -ef | grep tricky
mtxweb 11896 16920 0 14:47:40 pts/20 0:00 vi tricky2.cgi
mtxweb 28303 6556 0 15:04:12 pts/4 0:00 grep tricky
mtxweb 28291 11896 2 15:04:04 pts/20 0:01 /usr/bin/perl tricky2.cgi
I've browsed the ipc perldoc, but not quit sure I really understand what is
going on. What methodology do I need to use, to have the 2nd instance of the
cgi script pass the global variable in which I'm trying to control the
program to the 1st instance?
Here is the sample. Just starting counting by 1, and print the value,
forever. When the stop button is clicked, I want the first process to finish
by exiting the while loop and return control to the user.
#!/usr/bin/perl
use CGI;
$query = new CGI;
$done4 = 'Stop';
print $query->header;
print $query->start_html("Counter");
print "<h1>IPC</h1>\n";
&print_prompt($query);
&do_work($query);
&display_count();
print $query->end_html;
#########################
sub print_prompt
#########################
{
my($query) = @_;
print $query->start_form;
print "<p>counting by 1s<br>";
print "<br>";
print $query->submit('Action', 'Start');
print $query->submit('Action', 'Stop');
print "<br>";
print $query->endform;
print "<hr>";
}
#########################
sub do_work
#########################
{
my($query) = @_;
my(@values,$key);
print "<h3>Settings</h3>";
foreach $key ($query->param) {
print "<strong>$key</strong> -> ";
if ($key eq 'Action') {
$done4 = $query->param($key);
}
@values = $query->param($key);
print join(", ",@values),"<br>\n";
}
}
#########################
sub display_count
#########################
{
$i = 1;
print "DONE: ", $done4;
print "<br>";
while (1) {
last if ($done4 eq 'Stop');
print "I= ", $i++;
print "<br>";
}
}
Thanks,
Scott
(e-mail address removed)