Respected Monks,
Firstly Thank you very much for you help and your cooperation to solve many of our problems we face.
As of now I am working on CVS implemention in our project and building a Web Aplicaton for it. The client has a central CVS repository and none of other system has CVS installed on it. So wat he wanted is to tar up the directory he wanted to monitor for versioning and transfer it to the CVS server, then untar it then import and check out the working copy into the CVS server it self. After you get the working copy again tar it up and send it to the respective system.
Now we have a CVS enabled directory in our host system, so after some time if at ll he wants to check the -- directories
status or diff or commit the changes or revert it back.
He needs to tar it up and send the working copy to the CVS Server again and execute the concerned CVS commands there to find out wats the status or diff or commit changes etc .......
So to achieve this process I used Net:Telnet to connect to the remote systems and tar command and then Net::FTP to transfer them to the CVS repository and then connected to the CVS server thru same Net::Telnet and untar it and imported the directory if it for the first time or else I am using the commands to be executed to find out the status/commiting the directory changes.....
The main problem here is that it this process it is taking a considerable amount of time since we are traing it up and sending the directory to the server and then again untar and import it.
1. For Connect, Tar and Transfer I am using a generic subroutine.
sub cvs_tar_gzip()
{
($obt_host, $c_ip, $c_user, $c_passwd, $obt_srcfile) = ( shift
+, shift, shift, shift, shift );
chomp( $obt_host, $obt_srcfile, $c_ip, $c_user, $c_paswd );
my %KP = ( 1 => $obt_host);
my $REC = &GetRec( $hostfile, \%KP );
return "1->ERROR : $REC" if ( $REC =~ /(FAILED|NO\sRECORD)/ );
my ( $host, $ip, $user, $passwd, $supasswd, $pauser, $papasswd
+ ) = split(':',$REC );
return "ERROR : User not found" unless ( $user );
#print " Telnet to $sel_ip with User -> $user Password -> $pas
+swd <br> ";
my $t = Net::Telnet->new( -host => $ip , -timeout => 70, -errm
+ode => "return", Prompt=> $pmt);
return "ERROR : Telnet To '$host' Failed" unless ( $t );
$t->login( $user,$passwd );
my $errr = $t->errmsg;
return "ERROR : Login failed for '$host': $errr " if ( $t->err
+msg ) ;
my($ldir, $rfile) = $obt_srcfile =~ m/(.*)\/(.*)$/;
my @Files = ("$rfile") ;
my $chg_dir = " cd $ldir ";
@change_dir = $t->cmd( String => $chg_dir, Timeout => 300);
print " Changed to $ldir directory <br> ";
return "Error: $! " if ( "@change_dir" =~ /No\s+such\s+file\s+
+or\s+directory/g);
my $tar_file = "$obt_host". "_" . $rfile . ".tar";
my $tar_cmd = " tar -cvf "." $tar_file " . " $rfile ";
@tar_result = $t->cmd( String => $tar_cmd , Timeout => 30);
my $gzfile = $tar_file . ".gz";
if ( "@zip_result" eq "" )
{
#return " $tar_file.gz -> SuccessFully Done ! ";
print " <br> --> $tar_file.gz -> SuccessFully Done !
+";
}
else
{
return " Error : @zip_result ";
}
print qq{ CVS INFO => $c_ip, $c_user, $c_passwd <br> };
my $rdir = "/tmp/WA_CVS"; #### Need to inform to
+ the Client abt Temp Path
$prom = '/\w+>\s*/';
$ftp_session = "ftp \-n $c_ip ";
#return " ftp --> $ftp_session \n";
@Ftp_Session = $t->cmd(String => $ftp_session, Timeout => 60,
+Prompt => $prom);
print " Session : <br> @Ftp_Session <br> ";
$ftp_login = " user $c_user $c_passwd ";
@Ftp_Login = $t->cmd(String => $ftp_login , Timeout => 60 , Pr
+ompt => $prom);
print " Login : @Ftp_Login <br> ";
my $path = " $ldir/$gzfile $rdir/$gzfile ";
$ftp_cmd = " put $path ";
@Ftp_Cmd = $t->cmd(String => $ftp_cmd , Timeout => 60 , Prompt
+ => $prom);
print " Result : @Ftp_Cmd ";
print "<br> gunzip file --> $gzfile <br>";
$bye_cmd = "bye";
$t->cmd(String => $bye_cmd , Timeout => 60 , Prompt => $prom);
$cmd = "rm $gzfile";
&ExeCmd($t, $cmd);
$t->close;
my $ret_var_path = $rdir . "/". $gzfile;
return ( $ret_var_path );
}
print qq{ CVS INFO => $c_ip, $c_user, $c_passwd <br> };
my $rdir = "/tmp/WA_CVS"; #### Need to inform to
+ the Client abt Temp Path
$prom = '/\w+>\s*/';
$ftp_session = "ftp \-n $c_ip ";
#return " ftp --> $ftp_session \n";
@Ftp_Session = $t->cmd(String => $ftp_session, Timeout => 60,
+Prompt => $prom);
print " Session : <br> @Ftp_Session <br> ";
$ftp_login = " user $c_user $c_passwd ";
@Ftp_Login = $t->cmd(String => $ftp_login , Timeout => 60 , Pr
+ompt => $prom);
print " Login : @Ftp_Login <br> ";
my $path = " $ldir/$gzfile $rdir/$gzfile ";
$ftp_cmd = " put $path ";
@Ftp_Cmd = $t->cmd(String => $ftp_cmd , Timeout => 60 , Prompt
+ => $prom);
print " Result : @Ftp_Cmd ";
print "<br> gunzip file --> $gzfile <br>";
$bye_cmd = "bye";
$t->cmd(String => $bye_cmd , Timeout => 60 , Prompt => $prom);
$cmd = "rm $gzfile";
&ExeCmd($t, $cmd);
$t->close;
my $ret_var_path = $rdir . "/". $gzfile;
return ( $ret_var_path );
}
It is in this fashion and the other sub routines in athe same way to untar and import
2. Then Untar and import another subroutine.
3. Then tar the working copy and send it back to its host.
So, is there any other way or shall i use any other technique. Please help me out monks.
Thanks in advance.