Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

CVS Implementation in Perl / CGI

by msk_0984 (Friar)
on Aug 20, 2007 at 06:20 UTC ( [id://633714]=perlquestion: print w/replies, xml ) Need Help??

msk_0984 has asked for the wisdom of the Perl Monks concerning the following question:

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.

Sushil Kumar

Replies are listed 'Best First'.
Re: CVS Implementation in Perl / CGI
by moritz (Cardinal) on Aug 20, 2007 at 07:02 UTC
    So, is there any other way or shall i use any other technique. Please help me out monks.

    What about installing CVS? Or subversion, which is "CVS done right"?

    Or if that's not possible, did you take a look at Apache::CVS?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://633714]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-20 12:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found