PNG  IHDR* pHYs+ IDATx]n#; cdLb Ǚ[at¤_:uP}>!Usă cag޿ ֵNu`ݼTâabO7uL&y^wFٝA"l[|ŲHLN밪4*sG3|Dv}?+y߉{OuOAt4Jj.u]Gz*҉sP'VQKbA1u\`& Af;HWj hsO;ogTu uj7S3/QzUr&wS`M$X_L7r2;aE+ώ%vikDA:dR+%KzƉo>eOth$z%: :{WwaQ:wz%4foɹE[9<]#ERINƻv溂E%P1i01 |Jvҗ&{b?9g=^wζXn/lK::90KwrюO\!ջ3uzuGv^;騢wq<Iatv09:tt~hEG`v;3@MNZD.1]L:{ծI3`L(÷ba")Y.iljCɄae#I"1 `3*Bdz>j<fU40⨬%O$3cGt]j%Fߠ_twJ;ABU8vP3uEԑwQ V:h%))LfraqX-ۿX]v-\9I gl8tzX ]ecm)-cgʒ#Uw=Wlێn(0hPP/ӨtQ“&J35 $=]r1{tLuǮ*i0_;NƝ8;-vݏr8+U-kruȕYr0RnC]*ެ(M:]gE;{]tg(#ZJ9y>utRDRMdr9㪩̞zֹb<ģ&wzJM"iI( .ꮅX)Qw:9,i좜\Ԛi7&N0:asϓc];=ΗOӣ APqz93 y $)A*kVHZwBƺnWNaby>XMN*45~ղM6Nvm;A=jֲ.~1}(9`KJ/V F9[=`~[;sRuk]rєT!)iQO)Y$V ی ۤmzWz5IM Zb )ˆC`6 rRa}qNmUfDsWuˤV{ Pݝ'=Kֳbg,UҘVz2ﴻnjNgBb{? ߮tcsͻQuxVCIY۠:(V뺕 ٥2;t`@Fo{Z9`;]wMzU~%UA蛚dI vGq\r82iu +St`cR.6U/M9IENDB` REDROOM
PHP 5.6.40
Preview: 5.B.top Size: 2.39 KB
/proc/thread-self/root/usr/share/doc/perl-Expect/tutorial/5.B.top

#!/usr/bin/perl
#	Here we set manual_stty on the process so we can do things like
#hit ^Z to stop it instead of the ^Z going to the process on the other machine.
#	This is to say, normally when you interact with a process STDIN is
#put in raw mode so everything you type talks to the process at the other end.
#	Picture this. When you telnet somewhere and start a process (top
#for example) you are talking to telnet in raw mode. If you press ^Z it
#goes through telnet to the shell on the remote machine and the process
#at the other end is stopped. Here we're going to make it so raw mode is
#never set and when you press ^Z or ^C it will stop/interrupt Expect.
#	Also briefly demonstrated is the use of Expect::interconnect(),
#a more general/versatile alternative to interact.

use Expect;

# Debugging anyone?
# $Expect::Log_Stdout=1;
# $Expect::Exp_Internal=1;
# $Expect::Debug=1;

$RSH='/usr/bin/ssh';

$host_to_login_to=shift(@ARGV);



print "Enter password: ";
$|=1;
# 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,"\n");
 $password = $before;
# Turn echo back on
$stdin->exp_stty('echo');
# print that newline that wasn't echoed
print "\n";



#$Expect::Exp_Internal=1;

$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";

# We already have an inited handle for STDIN above which we can use.
# We don't just do $rsh->interact because it will go monkeying
# with tty settings by default (set it raw).
$stdin->manual_stty(1);
# Instead we use interconnect directly. 
# The trick here is to make sure:
# 1. Everything listening to a handle is added to its
# listen group.
# 2. Only what you want is jabbering at STDOUT.
# 
# In this case only $rsh will talk to STDOUT so we don't have to 
# change any log_stdout() settings.
$stdin->set_group($rsh);
Expect::interconnect($stdin,$rsh);


Directory Contents

Dirs: 0 × Files: 10

Name Size Perms Modified Actions
2.37 KB lrw-r--r-- 2017-05-15 15:55:28
Edit Download
3.01 KB lrw-r--r-- 2019-08-23 14:02:45
Edit Download
3.95 KB lrw-r--r-- 2019-08-23 14:02:45
Edit Download
1.93 KB lrw-r--r-- 2019-08-23 14:02:45
Edit Download
928 B lrw-r--r-- 2019-08-23 14:02:45
Edit Download
1.11 KB lrw-r--r-- 2019-08-23 14:02:45
Edit Download
2.39 KB lrw-r--r-- 2019-08-23 14:02:45
Edit Download
3.18 KB lrw-r--r-- 2019-08-23 14:02:45
Edit Download
1.79 KB lrw-r--r-- 2019-08-23 14:02:45
Edit Download
644 B lrw-r--r-- 2017-05-15 15:55:28
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).
© 2026 REDROOM — Secure File Manager. All rights reserved. Built with ❤️ & Red Dark UI