my $session = getSessionID();
my $cache = getCacheHandle();
$cache->set($session, [0, $buffer]);
#===== Fork off a child process to do the processing
if (my $pid = fork)
{
delete_all(); # get rid of old parameters
param('session', $session);
print redirect(self_url());
}
elsif (defined($pid))
{
close STDOUT;
open (STDOUT, "-|");
#===== Make the command files
$buffer .= "Creating command files...
";
$cache->set($session, [0, $buffer]);
createCommandFiles($cache);
$buffer .= "Done creating command files.
";
$cache->set($session, [1, $buffer]);
} # if the pid is defined
sub createCommandFiles($)
{
my $cache = shift or
die "Must supply cache to getVersionReports()!\n";
#===== Change directory to our directory
chdir($file_dir) or die "Couldn't chdir to $file_dir";
#===== Make each command file
foreach my $device (@selected_devices_array)
{
my $command = "$mkcmdfile -t \"$device\"";
system($command) and die
"Could not run command $command : $!";
$buffer .= "Created command file for $device.
";
#===== Update the display cache
$cache->set($session, [0, $buffer]);
}
} # end of createCommandFiles()
#===================================================================
# D I S P L A Y R E S U L T S
#===================================================================
sub displayPushResults($)
{
my $session = shift or
die "Must supply session id to displayPushResults()!\n";
my $cache = undef;
my $data = undef;
#===== Get a cache handle
$cache = getCacheHandle();
#===== Get the session info
$data = $cache->get($session);
#===== Check validity of session
die "Could not reconnect to your session!\n" unless ($data and ref $data eq 'ARRAY');
#===== Write the header
print "Content-type: text/html\n\n";
print "\n";
print "
\n"; #===== Print the results print "$data->[1]"; if (!$data->[0]) { print "
Still processing... please wait!
";
} # if the code push is not done yet
} # displayPushResults()