expect

expect, interact and then again expect

随声附和 提交于 2020-08-02 12:04:17
问题 There are several posts regarding the same, but i still not able to make my expect script work properly. My intention is to automate everything but leave the password enter for the user. So there are 3 parts of the script: automated login give the user interaction to enter the password give control back to Expect script to continue work So i have script which will be spawned and which have 3 read commands. First and last should be filled by Expect and second one i would like to enter my self:

expect, interact and then again expect

房东的猫 提交于 2020-08-02 12:03:48
问题 There are several posts regarding the same, but i still not able to make my expect script work properly. My intention is to automate everything but leave the password enter for the user. So there are 3 parts of the script: automated login give the user interaction to enter the password give control back to Expect script to continue work So i have script which will be spawned and which have 3 read commands. First and last should be filled by Expect and second one i would like to enter my self:

Can't find package from application written in Tcl

社会主义新天地 提交于 2020-05-17 06:22:06
问题 Thanks to the comments, better understand the problem a bit. The variables: thufir@dur:~/tcl/packages$ thufir@dur:~/tcl/packages$ echo 'puts $auto_path' | tclsh /usr/share/tcltk/tcl8.6 /usr/share/tcltk /usr/lib /usr/local/lib/tcltk /usr/local/share/tcltk /usr/lib/tcltk/x86_64-linux-gnu /usr/lib/tcltk /usr/lib/tcltk/tcl8.6 thufir@dur:~/tcl/packages$ thufir@dur:~/tcl/packages$ echo 'puts $tcl_pkgPath' | tclsh /usr/local/lib/tcltk /usr/local/share/tcltk /usr/lib/tcltk/x86_64-linux-gnu /usr/lib

What's the usage of `expect_before` command in Expect?

时光怂恿深爱的人放手 提交于 2020-05-16 22:37:28
问题 The doc says: takes the same arguments as expect , however it returns immediately. But what does it mean by "returns immediately" ? What's the usage of this command could be ? 回答1: Image you have spawned a program that, say, randomly asks "Are you sure [yn]?" Imagine this program has 100 questions that need to be answered. You don't want to have to conditionally expect an "Are you sure" question for each of those 100 questions. Expect lets you do: spawn /some/annoying/program expect_before {

What's the usage of `expect_before` command in Expect?

只愿长相守 提交于 2020-05-16 22:37:00
问题 The doc says: takes the same arguments as expect , however it returns immediately. But what does it mean by "returns immediately" ? What's the usage of this command could be ? 回答1: Image you have spawned a program that, say, randomly asks "Are you sure [yn]?" Imagine this program has 100 questions that need to be answered. You don't want to have to conditionally expect an "Are you sure" question for each of those 100 questions. Expect lets you do: spawn /some/annoying/program expect_before {

expect脚本同步文件、expect脚本指定host和同步的文件、构建文件分发系统、批量远程执行命

懵懂的女人 提交于 2020-03-30 11:44:42
expect脚本当中去把一台机器的文件同步到另外一台机器上去,自动同步文件 [root@100xuni1 sbin]# vim 4.expect ##编辑脚本 写入一下内容: #!/usr/bin/expect set passwd "hanshuo" spawn rsync -av root@192.168.63.101:/tmp/12.txt /tmp/ expect { "yes/no" { send "yes\r"} "password:" { send "$passwd\r" } } expect eof 加个执行权限 [root@100xuni1 sbin]# chmod a+x 4.expect 测试这个脚本 [root@100xuni1 sbin]# ./4.expect expect脚本指定host和要同步的文件 指定host和要同步的文件 [root@100xuni1 sbin]# vim 5.expect ##编辑脚本 写入一下内容: #!/usr/bin/expect set passwd "hanshuo" set host [lindex $argv 0] set file [lindex $argv 1] spawn rsync -av $file root@$host:$file ##同步文件本机到对方 expect { "yes/no" {

第九周作业

独自空忆成欢 提交于 2020-03-29 17:21:11
1、编写脚本,接受二个位置参数,magedu和/www,判断系统是否有magedu,如果没有则自动创建magedu用户,并自动设置家目录为/www [root@centos6 ~]#cat usermagedu.sh #!/bin/bash #接受二个位置参数,magedu和/www,判断系统是否有magedu,如果没有则自动创建magedu用户,并自动设置家目录为/www id $1 &>/devnull if [ $? -eq 0 ];then echo 用户$1 已存在! else useradd -d $2 $1 && echo "用户$1 已创建,家目录为$2 !" fi [root@centos6 ~]#bash usermagedu.sh root 用户root 已存在! [root@centos6 ~]#bash usermagedu.sh magedu /www 用户magedu 已创建,家目录为/www ! [root@centos6 ~]#bash usermagedu.sh magedu /www 用户magedu 已存在! [root@centos6 ~]#id magedu uid=2005(magedu) gid=2005(magedu) groups=2005(magedu) [root@centos6 ~]#tail -1 /etc/passwd