CVS access via PERL

H

Holger Biebinger

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
 
P

Paul Lalli

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
 
H

Holger Biebinger

Hi,

Paul said:
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::path;
use File::Basename;
use File::Copy;
use File::Spec;
use File::DosGlob '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
 
P

Paul Lalli

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::path;
use File::Basename;
use File::Copy;
use File::Spec;
use File::DosGlob '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{CVS_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
 
H

Holger Biebinger

Hi,

Paul said:
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.
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{CVS_SERVER}:$config{CVS_DIR}";

Well. It's mildly better anyway.
Really, its better. Thanks for that hint.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top