#!/usr/bin/expectset timeout 60if {$argc != 3} { send "usage followed by src,dst,password" exit}set src [lindex $argv 0]set dst [lindex ...
分类:
其他好文 时间:
2014-09-22 18:46:22
阅读次数:
186
1.通过sshpass让ssh记住密码实现ssh自动登陆
(1)安装sshpass
sudoapt-getinstallsshpass
或者
下载sshpass-1.05.tar.gz
shell>tarxvfsshpass-1.05.tar.gz
shell>cdsshpass-1.05
shell>make&&makeinstall
(2)测试
shell>/usr/local/bin/sshpass-p密码ss..
分类:
其他好文 时间:
2014-09-17 18:53:53
阅读次数:
225
1. [#!/usr/bin/expect] 这一行告诉操作系统脚本里的代码使用那一个shell来执行。这里的expect其实和linux下的bash、windows下的cmd是一类东西。 注意:这一行需要在脚本的第一行。 2. [set timeout 30] 基本上认识英文的都知道这是设置超时时...
分类:
其他好文 时间:
2014-09-15 22:42:39
阅读次数:
664
expect是一种能够按照脚本内容里面设定的方式与交互式程序进行“会话”的程序。根据脚本内容,Expect可以知道程序会提示或反馈什么内容以及 什么是正确的应答。它是一种可以提供“分支和嵌套结构”来引导程序流程的解释型脚本语言。shell功能很强大,但是不能实现有交互功能的多机器之前的操作,例如ss...
分类:
系统相关 时间:
2014-09-12 18:55:33
阅读次数:
375
#!/bin/bashforipin`catiplist.txt`dopwd=`mkpasswd-l12-s0-C0`grep-q$ip/root/pwd.log&&passwd=$(grep$ip/root/pwd.log|cut-d:-f2)||passwd=123456expect-c"spawnsshroot@$ippasswdexpect{\"*yes/no*\"{send\"yes\r\";exp_continue}\"*password*\"{send\"$passwd\r\";..
分类:
其他好文 时间:
2014-09-11 19:33:52
阅读次数:
237
Description
Problem A
Expect the Expected
Input: Standard Input
Output: Standard Output
Some mathematicalbackground. This problem asks you to compute the expected value of arandom variable...
分类:
其他好文 时间:
2014-08-29 16:03:58
阅读次数:
218
#!/bin/baship="172.16.1.113"command="ssh$ip"expect-c"spawn$command;expect{\"Areyousureyouwanttocontinueconnecting(yes/no)?\"{send\"yes\r\";exp_continue}}"
分类:
其他好文 时间:
2014-08-24 10:23:32
阅读次数:
414
#!/usr/bin/expectset timeout 30spawn ssh fangkui@172.100.101.150expect { "fangkui@172.100.101.150's password:" {send "652289237\r"}}interact
分类:
其他好文 时间:
2014-08-19 16:27:34
阅读次数:
216
在linux系统中,如何用shell脚本抓取远程日志?分析线上的日志会有一个困境,机器太多,如果每台都登录上去看不太现实,但是下载下来更麻烦因为每台SCP都要求输入密码。于是我便写了一个自动抓取远程日志的脚本,实现在基本功能。代码:#!/usr/bin/expect -fif { $argc !=1...
分类:
其他好文 时间:
2014-08-15 23:40:09
阅读次数:
327