Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
# Add the next 2 lines to bash_profile/bashrc file: # # eval `ssh-agent` > /dev/null # alias cvs='/path/to/' # #!/usr/bin/perl use strict; use warnings; use Expect; #$Expect::Exp_Internal = 1; #$Expect::Debug = 3; my $testcommand = Expect->spawn("ssh-add -l"); $testcommand->log_stdout(0); if ($testcommand->expect(1, '-re' => 'agent has')) { $testcommand->soft_close(); print "CVS Wrapper\n===========\n\n"; GET_PASSWD: { use Term::ReadKey; ReadMode 2; print "Enter cvs passwd:"; my $passwd = <STDIN>; chomp $passwd; ReadMode 0; unless (length $passwd > 4) { print "\nBad password\n"; redo GET_PASSWD; } my $user = $ENV{'USER'}; my $home = $ENV{'HOME'}; my $remoteserv = ''; my $login = "$user" . '@' . "$remoteserv"; unless (-e "$home/.ssh/") { # Set up private keys my $command = Expect->spawn("ssh-keygen -t dsa"); $command->log_stdout(0); if ($command->expect(2, '-re' => 'Enter')) { print $command "\r"; } if ($command->expect(2, '-re' => 'passphrase')) { print $command "$passwd\r"; } if ($command->expect(2, '-re' => 'same')) { print $command "$passwd\r"; } $command->soft_close(); my $copy_command = Expect->spawn("scp ~/.ssh/ $remot +eserv:.ssh/authorized_keys2"); $copy_command->log_stdout(0); if ($copy_command->expect(2, "password")) { print $copy_command "$passwd\r"; } if ($copy_command->expect(3, '-re' => 'denied')) { $copy_command->hard_close(); print "\nBad password\n"; unlink "$home/.ssh/", "$home/.ssh/id_dsa"; redo GET_PASSWD; } $copy_command->soft_close(); } my $ssha_command = Expect->spawn("ssh-add"); $ssha_command->log_stdout(0); if ($ssha_command->expect(2, "passphrase")) { print $ssha_command "$passwd\r"; } if ($ssha_command->expect(1,'-re' =>'Bad')) { $ssha_command->hard_close(); print "\nBad password\n"; redo GET_PASSWD; } $ssha_command->soft_close(); print "\nLogin successful\n"; } #end GET_PASSWD } else { $testcommand->soft_close(); } open DATA, "/usr/bin/cvs @ARGV |" or die "Couldn't execute program: $! +"; while ( defined( my $line = <DATA> ) ) { chomp($line); print "$line\n"; } close DATA;

In reply to cvs wrapper with ssh-agent by jacques

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (5)
    As of 2019-11-17 10:02 GMT
    Find Nodes?
      Voting Booth?
      Strict and warnings: which comes first?

      Results (86 votes). Check out past polls.