Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

How do I send passwd via Expect.pm w/o printing it clear text to screen

by perlknight (Pilgrim)
on Feb 24, 2002 at 16:54 UTC ( [id://147180]=perlquestion: print w/replies, xml ) Need Help??

perlknight has asked for the wisdom of the Perl Monks concerning the following question: (input and output)

I need to know if it's possible to print encode blanks or some other types of character while sending password to expect FH. If so, how? Thanks for your input.

sub copyover { my $scp=Expect->spawn("/usr/bin/scp -r \"$srcpath\" ${dest_hos +t}:$destpath"); my $spawn_ok; $scp->expect(30, [ qr'ssword: ', sub { $spawn_ok=1; print $scp ("password\n"); exp_continue; } ], [ qr'yes/no', sub { $spawn_ok=1; $scp->send("yes\n"); exp_continue; } ], '-re', qr'[#>:] $', #' ); $scp->soft_close(); return; }

Originally posted as a Categorized Question.

  • Comment on How do I send passwd via Expect.pm w/o printing it clear text to screen
  • Download Code

Replies are listed 'Best First'.
Re: How do I send passwd via Expect.pm w/o printing it clear text to screen
by zengargoyle (Deacon) on Feb 24, 2002 at 20:10 UTC

    I think you want:

    [ qr'ssword: ', sub { $spawn_ok=1; $scp->stty('-echo'); # echo off print $scp ("password\n"); $scp->stty('echo'); # echo on exp_continue; } ],

    (untested, don't have Expect installed)

Re: How do I send passwd via Expect.pm w/o printing it clear text to screen
by zengargoyle (Deacon) on Feb 24, 2002 at 20:52 UTC

    Update: that might need to be $scp->slave_pty->stty('-echo') and $scp->slave_pty->stty('echo'). or you might need to use one of the $obj->log_* or Expect::Log_* function/variables to tweak what gets displayed where and when.

Re: How do I send passwd via Expect.pm w/o printing it clear text to screen
by perlknight (Pilgrim) on Feb 25, 2002 at 01:43 UTC
    zengargoyle, thanks for taking the time to replied; it's just what I needed :-)

    Originally posted as a Categorized Answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://147180]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-25 08:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found