D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
usr
/
share
/
doc
/
perl-Expect
/
tutorial
/
Filename :
5.A.top
back
Copy
#!/usr/bin/perl # Here we are doing this again only this time we'll do it #without Echoing the password. $RSH='/usr/bin/ssh'; $host_to_login_to=shift(@ARGV); use Expect; print "Enter password: "; # First we have to initialize STDIN in to an expect object. $stdin=Expect->exp_init(\*STDIN); # Now turn off echoing $stdin->exp_stty('-echo'); # The easy way to do this is: #$password=<STDIN>; #chop $password; # The somewhat harder way is to use $stdin->expect. This would look like: # ($match_num,$error,$match,$before,$after)=$stdin->expect(undef,"\r"); $password = $before; # Turn echo back on $stdin->exp_stty('echo'); # print that newline that wasn't echoed print "\n"; $rsh=Expect->spawn($RSH,$host_to_login_to); # Look for a password prompt. $rsh->expect(30,'-re','word:\s$')||(die"Never got password prompt\n"); print $rsh "$password\r"; # Look for a prompt. Prompt can be # $ > or ] followed by a whitespace. $prompt = '[\]\$\>\#]\s$'; # Note the use of -re $rsh->expect(30,'-re',$prompt)||(die "Never got prompt on host\n"); # Start top print $rsh "exec top\r"; # OK, now return control to user. $rsh->interact();
Name
Size
Last Modified
Owner
Permissions
Actions
1.A.Intro
2.371
KB
May 15 2017 3:55:28
root
0644
2.A.ftp
3.013
KB
August 23 2019 2:02:45
root
0644
2.B.rlogin
3.948
KB
August 23 2019 2:02:45
root
0644
3.A.debugging
1.927
KB
August 23 2019 2:02:45
root
0644
4.A.top
0.906
KB
August 23 2019 2:02:45
root
0644
5.A.top
1.112
KB
August 23 2019 2:02:45
root
0644
5.B.top
2.393
KB
August 23 2019 2:02:45
root
0644
6.A.smtp-verify
3.184
KB
August 23 2019 2:02:45
root
0644
6.B.modem-init
1.79
KB
August 23 2019 2:02:45
root
0644
README
0.629
KB
May 15 2017 3:55:28
root
0644
2017 © D7net | D704T team