⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 5.a.top

📁 测试中用于交互的一个脚本.在自动化脚本中会用得到.希望对您有帮助.
💻 TOP
字号:
#!/usr/local/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 echoedprint "\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 topprint $rsh "exec top\r";# OK, now return control to user.$rsh->interact();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -