All,
It has been some time since I posted, mainly because I do not have many Perl
projects, but as always I am turning to you all for your infinite wisdom. I
have written a web-based script that will promote files from a source server
to a destination server utilizing rsync. I would like to add a progress bar
indicator to the script that will display status on the web page until the
file sync complete. Can anyone shed some light? I have reviewed
CGI:ProgressBar, but have had no success in implementing. Code is attached
below.
#!/usr/bin/perl -w
# perlPromote.cgi by John Pretti
# Comments/Questions john[at]web-connected.com
# Last modified 05/17/04
# Load needed Perl modules
use strict;
use diagnostics;
use CGI; #Make HTML east to deal with
use CGI::Carp 'fatalsToBrowser'; # Report errors to Browser
use File::Slurp;
# SCP commands
my $ssh_cmd = "ssh -i /home/apache/.ssh/apache_whitep3_dsa -o ForwardX11=no
";
# Current Working Directory
my $src_dir = "/var/www/recdoc/Value-AddedProducerGrant/test/*";
my $dst_dir = "cygdrive/d/WebData/ValueAdded/test";
# Promotion Servers
my $test_srv = "some.serv";
my $cert_srv = "some.serv2";
my $prod_srv = "some.serv3";
# Create New CGI Object
my $q = new CGI;
my %label = ('Test'=>'Test',
'Certification'=>'Certification',
'Production'=>'Production');
if ( $q->param('promdir') ) {
# Synchronize directories
if ( $q->param('promdir') eq "Test" ) {
system (`rsync --delete $src_dir -e "$ssh_cmd"
[EMAIL PROTECTED]:/$dst_dir`)
} elsif ( $q->param('promdir') eq "Certification" ) {
system (`rsync --delete $src_dir -e "$ssh_cmd"
[EMAIL PROTECTED]:/$dst_dir`)
} else {
system (`rsync --delete $src_dir -e "$ssh_cmd"
[EMAIL PROTECTED]:/$dst_dir`)
}
# Print success
print $q->header();
print read_file('../../html/merlin/htmlheadps.html');
print $q->p("The directories have been synchronized.");
print read_file('../../html/merlin/htmlfootps.html');
# Print form on first run
} elsif ($q->param('Synchronize') ) {
print $q->header();
print read_file('../../html/merlin/htmlheadp.html');
print $q->p("Please select an environment prior to pressing
Synchronize.");
print $q->start_multipart_form,
$q->p("Please select an environment for synchronization:"),
$q->radio_group (
-name=>'promdir',
-values=> ['Test','Certification','Production'],
-labels=>\%label,
-default=>'selected',
-linebreak=>'true'),
$q->br,
$q->submit('Synchronize'),
$q->end_form;
print read_file('../../html/merlin/htmlfootp.html');
} else {
print $q->header();
print read_file('../../html/merlin/htmlheadp.html');
print $q->start_multipart_form,
$q->p("Please select an environment for synchronization:"),
$q->radio_group (
-name=>'promdir',
-values=> ['Test','Certification','Production'],
-labels=>\%label,
-default=>'selected',
-linebreak=>'true'),
$q->br,
$q->submit('Synchronize'),
$q->end_form;
print read_file('../../html/merlin/htmlfootp.html');
}
Thanks,
John