1.expect实现参数传递1.1实现$argv参数数组expect脚本可以接受从bash传递过来的参数。可以使用[lindex$argvn]获得,n从0开始,分别表示第一个,第二个,第三个....参数1.2样例cattelnet.exp#!/usr/bin/expectsethost[lindex$argv0]setpasswd[lindex$argv1]setpasswden[lindex$arg..
分类:
其他好文 时间:
2016-05-10 23:57:21
阅读次数:
678
第一题ssh客户端
[lsc888@m01~]$ssh-keygen-tdsa-P‘‘-f~/.ssh/id_dsa
Generatingpublic/privatedsakeypair.
eateddirectory‘/home/lsc888/.ssh‘.
Youridentificationhasbeensavedin/home/lsc888/.ssh/id_dsa.
Yourpublickeyhasbeensavedin/home/lsc888/.ssh/id_dsa.pub.
Thekey..
分类:
系统相关 时间:
2016-05-10 23:46:12
阅读次数:
403
zebra@zebra-PC /cygdrive/c/tool/mirantis/vbox-scripts-7.0/virtualbox
$ sh launch.sh
Checking for 'free'... OK
Checking for 'expect'... OK
If you run this script under Cygwin, you may have to add p...
分类:
其他好文 时间:
2016-05-07 11:04:31
阅读次数:
329
if [ ! $# -eq 2 ] ;then
echo "请输入用户密码以空格分开"
exit
else
ssh-keygen -t rsa
#用户名
uname="$1"
#密码
passwd="$2"
fi
#执行检测并安装expect模块
ep=`rpm -qa | grep expect`
if [ -z $ep ] ; then
echo "检测到你的系统,没有安装e...
分类:
其他好文 时间:
2016-05-07 07:59:53
阅读次数:
139
dr-mysql01:/root# cat a1.sh
#用户名
uname="$1"
#密码
passwd="$2"
#执行检测并安装expect模块
ep=`rpm -qa | grep expect`
if [ -z $ep ] ; then
echo "检测到你的系统,没有安装expect模块,准备执行安装"
sleep 2
yum install -y expect
...
分类:
其他好文 时间:
2016-05-07 07:59:36
阅读次数:
138
##/bin/bashpassword=‘Aa123456‘foruserin$(cat./user_id)do/usr/bin/expect<<Eofsettimeout10expect"*#"spawn/usr/sbin/useradd${user}expect"*#"spawn/usr/bin/passwd${user}expect{"*password:"{send"$password\r";exp_continue}"*password:"{send"$password\r"}}Eofdone
分类:
其他好文 时间:
2016-05-07 01:17:42
阅读次数:
178
#!/usr/bin/expectset user [lindex $argv 0]set pass [lindex $argv 1]spawn useradd -s /bin/sh -d /home/$user $userexpect "*#"spawn passwd $userexpect "* ...
分类:
其他好文 时间:
2016-05-05 17:40:54
阅读次数:
127
yum install expect -y which expect #!/bin/bash . /etc/init.d/functions file="$1" remote_dir="$2" if [[ $# -ne 2 ]];then echo "usage:$0 argv2" echo "mu... ...
分类:
其他好文 时间:
2016-05-05 08:25:06
阅读次数:
154
简单需求来讲解shell+expect先安装下expect,yum安装yuminstallexpect-y#!/bin/baship=‘192.168.80.20‘#定义远程交换服务器的IPpassword=‘test@2015‘#定义输入的密码expect<<EOFspawnsshroot@$ipls#在expect中执行命令settimeout-1#定义超时时间,-1为永不超时expect"*:"..
分类:
系统相关 时间:
2016-05-04 19:34:43
阅读次数:
270
近来经常要通过ssh登录服务器,每次输入命令和密码很麻烦,查资料发现有两种解决,一种是本地创建密钥直接登录,另一种是写个脚本。 这里介绍第二种方法,第一种资料也很多,但是觉得没啥意思。 先上脚本: 再来一行行解释: 首先解释一下这个expect命令,根据其中文含义也可以猜出来,就是期望出现什么,然后 ...
分类:
系统相关 时间:
2016-04-23 16:23:03
阅读次数:
269