Perl Monks, I am trying to use user input for username and password. Then run password to change the current password. I seem to having issues passing the input the first time. If I put the username and password in the script it works but soon as I put the variables I get the error on line 34. Here is my code and here are the errors as well. Thank you in advance.


#!/usr/bin/perl use strict; use warnings; use Net::SSH::Expect; print "Enter your username: "; my $unme =<>; print "Enter current passwd: "; system('stty','-echo'); chop(my $cur_pswd =<STDIN>); system('stty','echo'); print "\n", "Enter new passwd: "; system('stty','-echo'); chop(my $new_pswd =<STDIN>); system('stty','echo'); print "\n", "Enter new passwd again: "; system('stty','-echo'); chop(my $val_pswd =<STDIN>); system('stty','echo'); print"\n"; if ($new_pswd eq $val_pswd){ my $ssh = Net::SSH::Expect->new( host => 'localhost', user => "$unme", password => "$cur_pswd", raw_pty => 1 ); warn "Starting SSH... \n"; $ssh->run_ssh(); warn "Testing login output... \n"; my $login_output = $ssh->login(); print " Done", "\n"; my $who = $ssh->exec('who'); print($who); } else{ print "wrong password ! \n"; }

Error>>>>>> Pseudo-hashes are deprecated at /usr/lib/perl5/site_perl/5.8.0/Net/SSH/Expect.pm line 60, <STDIN> line 3.,
Pseudo-hashes are deprecated at /usr/lib/perl5/site_perl/5.8.0/Net/SSH/Expect.pm line 60, <STDIN> line 3.
Pseudo-hashes are deprecated at /usr/lib/perl5/site_perl/5.8.0/Net/SSH/Expect.pm line 60, <STDIN> line 3.
Pseudo-hashes are deprecated at /usr/lib/perl5/site_perl/5.8.0/Net/SSH/Expect.pm line 60, <STDIN> line 3.
Starting SSH...
Testing login output...
SSHProcessError The ssh process was terminated. at ./ssh_example line 34


In reply to using user input with net::ssh:expect by daudlm

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.