Hi,

I'm stuck on what's the best way to automate the following set of commands in perl:

cvs login Logging in to :pserver:ebizadmin@localhost:2401/usr/local/cvsroot CVS password: cd /home/js/apache/dd cvs import -m \"First configuration\" apache/dd ebizadmin start

I started a perl script using Expect, and managed to get as far as logging into cvs, but then wasn't sure how to run the cd, and cvs import commands (Sorry haven't used Expect before). This is as far as I've got but obviously it doesn't work:

#!/usr/bin/perl use Expect; #$Expect::Debug = 1; my $cvsroot=":pserver:ebizadmin@localhost:/usr/local/cvsroot"; my $password="secret"; $timeout=3; my $exp = Expect->spawn("cvs login") or die "Cannot spawn cvs login: $ +!\n";; my $spawn_ok; $exp->expect($timeout, [ 'CVS password: $', sub { my $fh = shift; print $fh "$password\n"; print $fh "cd /home/js/apache/dd\n"; print $fh "cvs import -m \"First configuration\" apa +che/dd ebizadmin start"; exp_continue; } ], [ timeout => sub { die "No login.\n"; } ]

Any pointers on the right way to do this would be much appreciated. By the way, the Cvs module on cpan doesn't do cvs import before tells me to use that!

Many thanks,

js.


In reply to automating some cvs commands by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.