Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > CVS access via PERL

Reply
Thread Tools

CVS access via PERL

 
 
Holger Biebinger
Guest
Posts: n/a
 
      04-19-2004
Hi NG,
I would like to access a CVS Server which provides pserverv access. I
tried to access via
cvs [Directory here] login
After that i get a login prompt. Can I enter my password with PERL? I am
a beginner in using the PERL language.
I would appreciate any help.

Holger

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      04-19-2004
On Mon, 19 Apr 2004, Holger Biebinger wrote:

> Hi NG,
> I would like to access a CVS Server which provides pserverv access. I
> tried to access via
> cvs [Directory here] login
> After that i get a login prompt. Can I enter my password with PERL? I am
> a beginner in using the PERL language.
> I would appreciate any help.
>


The first help you'll get is a bunch of people telling you the language's
name is "Perl" not "PERL". Please follow that advice.

The second piece of advice I'll give is that you may want to check out the
CVS module at http://search.cpan.org/~rsoliv/Cvs-0.06/lib/Cvs.pm

The third piece of advice is that you should read the Posting Guidelines
which are posted regularly to the group. Specifically in this case,
please pay attention to the bit that tells you to "Speak Perl, not
English". That is, what do you mean when you said "I tried to access via
cvs [Directory here] login". Did you execute a system command? Are you
redirecting your Perl script to or from the CVS command? Show us what
you're doing.

Paul Lalli
 
Reply With Quote
 
 
 
 
Holger Biebinger
Guest
Posts: n/a
 
      04-19-2004
Hi,

Paul Lalli wrote:

> On Mon, 19 Apr 2004, Holger Biebinger wrote:
>
>>I would like to access a CVS Server which provides pserverv access. I
>>tried to access via
>>cvs [Directory here] login
>>After that i get a login prompt. Can I enter my password with PERL? I am
>>a beginner in using the PERL language.
>>I would appreciate any help.
>>

>
> The first help you'll get is a bunch of people telling you the language's
> name is "Perl" not "PERL". Please follow that advice.
>

Ok thanks. I will follow that advice.

> The second piece of advice I'll give is that you may want to check out the
> CVS module at http://search.cpan.org/~rsoliv/Cvs-0.06/lib/Cvs.pm
>

I will have a look at it. Thanks for that hint.

> The third piece of advice is that you should read the Posting Guidelines
> which are posted regularly to the group. Specifically in this case,
> please pay attention to the bit that tells you to "Speak Perl, not
> English". That is, what do you mean when you said "I tried to access via
> cvs [Directory here] login". Did you execute a system command? Are you
> redirecting your Perl script to or from the CVS command? Show us what
> you're doing.
>


Ok, let me try to speak Perl. I'm afraid I have quite a bad accent I
have a config file with the CVS access data and i want to connect to the
cvs server for a checkout:

test.cfg (the config file)
# CVS Variables
CVS_SERVER = 192.168.0.1
CVS_DIR = /usr/cvs
CVS_RSH = pserver

CVS_USERNAME = holger
CVS_PASSWORD = test

# webEdition Revision Variables
PROJECT = testproject
RELEASE = REL_0_1

test.pl
#!/usr/bin/perl -w

# I don't exactly know if I need all those packages
use File::Find;
use File:ath;
use File::Basename;
use File::Copy;
use File::Spec;
use File:osGlob 'glob'; # TinyPerl only seems to work with DosGlob :-/
use FileHandle;
use Getopt::Std;
use Config;

%config = (
);

$scriptbase = dirname($0);
$configfile = "$scriptbase/testfile.cfg" unless $configfile;
parse_cfg($configfile);

my $cvs ="cvs -d
:$config{'CVS_RSH'}:$config{'CVS_USERNAME'}"."@"." $config{'CVS_SERVER'}:"."$config{'CVS_DIR'}";
my $release = $config{'RELEASE'};
my $project = $config{'PROJECT'};
my $checkoutdir = $config{'CHECKOUTDIR'};

system "$cvs login";
#how can I enter the password?
system "$cvs co $project";

sub parse_cfg {
my $inifile = shift;
my ($var, $val);

open(CONFIG, $configfile) || die ("Error opening $configfile !");
print("Config File opened!\n");
while(<CONFIG>) {
next if /^\s*#/;
next unless /(\w+)\s*=\s*(.+)/;

($var, $val) = ($1, $2);

$config{$var} = $val;
}
close(CONFIG);
}

Thanks again.
Holger

 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      04-19-2004
On Mon, 19 Apr 2004, Holger Biebinger wrote:

> Ok, let me try to speak Perl. I'm afraid I have quite a bad accent I
> have a config file with the CVS access data and i want to connect to the
> cvs server for a checkout:
>
> test.pl
> #!/usr/bin/perl -w
>
> # I don't exactly know if I need all those packages
> use File::Find;
> use File:ath;
> use File::Basename;
> use File::Copy;
> use File::Spec;
> use File:osGlob 'glob'; # TinyPerl only seems to work with DosGlob :-/
> use FileHandle;
> use Getopt::Std;
> use Config;


The only one I see you using here are File::Basename (for dirname()). I
would recommend getting rid of the rest (and if the interpreter gives you
an error, then you know you should add it back. )

>
> %config = (
> );
>
> $scriptbase = dirname($0);
> $configfile = "$scriptbase/testfile.cfg" unless $configfile;
> parse_cfg($configfile);
>
> my $cvs ="cvs -d
> :$config{'CVS_RSH'}:$config{'CVS_USERNAME'}"."@"." $config{'CVS_SERVER'}:"."$config{'CVS_DIR'}";


Gahh. That looks rather messy. You might want to take advantage of the
hashkey property of barewords, not to mention escaping @ characters:

my $cvs ="cvs -d :$config{CVS_RSH}:$config{CVS_USERNAME}\@$config{C VS_SERVER}:$config{CVS_DIR}";

Well. It's mildly better anyway.

> my $release = $config{'RELEASE'};
> my $project = $config{'PROJECT'};
> my $checkoutdir = $config{'CHECKOUTDIR'};
>
> system "$cvs login";
> #how can I enter the password?
> system "$cvs co $project";
>


Okay. Now I understand. The simple answer is that you can't, at least not
like this. What you're trying to do is called "bidirectional interprocess
communication". That is, both getting input from and sending output to a
process. This is more complicated than you might imagine. For more
details, read:
perldoc -q pipe

That documentation will refer you to the IPC::Open2 module. However,
since you are trying to do something very specific with your bidirectional
pipe - something that many people before you have wanted to do - there
already exists a module specifically for it. I therefore refer you back
to the CVS module from CPAN that I posted in my previous message.


Paul Lalli

> sub parse_cfg {
> my $inifile = shift;
> my ($var, $val);
>
> open(CONFIG, $configfile) || die ("Error opening $configfile !");
> print("Config File opened!\n");
> while(<CONFIG>) {
> next if /^\s*#/;
> next unless /(\w+)\s*=\s*(.+)/;
>
> ($var, $val) = ($1, $2);
>
> $config{$var} = $val;
> }
> close(CONFIG);
> }
>
> Thanks again.
> Holger
>
>

 
Reply With Quote
 
Holger Biebinger
Guest
Posts: n/a
 
      04-20-2004
Hi,

Paul Lalli wrote:

> On Mon, 19 Apr 2004, Holger Biebinger wrote:
>
>
>>Ok, let me try to speak Perl. I'm afraid I have quite a bad accent I
>>have a config file with the CVS access data and i want to connect to the
>>cvs server for a checkout:
>>
>>test.pl
>>#!/usr/bin/perl -w
>>
>># I don't exactly know if I need all those packages
>>use File::Find;
>>use File:ath;
>>use File::Basename;
>>use File::Copy;
>>use File::Spec;
>>use File:osGlob 'glob'; # TinyPerl only seems to work with DosGlob :-/
>>use FileHandle;
>>use Getopt::Std;
>>use Config;

>
>
> The only one I see you using here are File::Basename (for dirname()). I
> would recommend getting rid of the rest (and if the interpreter gives you
> an error, then you know you should add it back. )
>
>

Ok you were right. It was the only one needed.

>>%config = (
>>);
>>
>>$scriptbase = dirname($0);
>>$configfile = "$scriptbase/testfile.cfg" unless $configfile;
>>parse_cfg($configfile);
>>
>>my $cvs ="cvs -d
>>:$config{'CVS_RSH'}:$config{'CVS_USERNAME'}"."@" ."$config{'CVS_SERVER'}:"."$config{'CVS_DIR'}";

>
>
> Gahh. That looks rather messy. You might want to take advantage of the
> hashkey property of barewords, not to mention escaping @ characters:
>
> my $cvs ="cvs -d :$config{CVS_RSH}:$config{CVS_USERNAME}\@$config{C VS_SERVER}:$config{CVS_DIR}";
>
> Well. It's mildly better anyway.
>

Really, its better. Thanks for that hint.

>
>>my $release = $config{'RELEASE'};
>>my $project = $config{'PROJECT'};
>>my $checkoutdir = $config{'CHECKOUTDIR'};
>>
>>system "$cvs login";
>>#how can I enter the password?
>>system "$cvs co $project";
>>

>
>
> Okay. Now I understand. The simple answer is that you can't, at least not
> like this. What you're trying to do is called "bidirectional interprocess
> communication". That is, both getting input from and sending output to a
> process. This is more complicated than you might imagine. For more
> details, read:
> perldoc -q pipe
>

OK. it is not quite easy It was the humble try of a beginner.

> That documentation will refer you to the IPC::Open2 module. However,
> since you are trying to do something very specific with your bidirectional
> pipe - something that many people before you have wanted to do - there
> already exists a module specifically for it. I therefore refer you back
> to the CVS module from CPAN that I posted in my previous message.
>

I tried it out and it seems to work for my purposes. Great. Next time I
will first have a look if anyone else has already done the work for me
Now I know where to search.

Holger

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Eclipse and CVS, Eclipse wipes out CVS directories xyzzy12@hotmail.com Java 1 08-31-2007 10:19 AM
Eclipse 3.2 and CVS - where and how to get and install CVS? ddog Java 3 08-04-2007 06:41 PM
[ANN] Ruby CVS IRC bot, and Ruby CVS RSS feed David Ross Ruby 5 12-05-2004 03:48 AM
How to capture output of CVS via Perl? Chris Weiss Perl Misc 7 10-09-2004 01:53 PM
How to capture output of CVS via Perl? Chris Weiss Perl Misc 1 10-08-2004 10:57 PM



Advertisments