expect

Formatting Expect Script Inside of User Command in Bash Script

偶尔善良 提交于 2019-12-24 17:42:12
问题 So I have three installers for NVIDIA's CUDA API -- the first is a driver and comes with nice silent install flag options (but you have to be root and have to have run level 3). The second two follow are shown manually installing below (cut out the long mess of install afterwards for brevity) [root]# sh cudatoolkit_4.1.28_linux_64_rhel5.x.run Verifying archive integrity... All good. Uncompressing NVIDIA CUDA......................................................................................

Formatting Expect Script Inside of User Command in Bash Script

本小妞迷上赌 提交于 2019-12-24 17:41:39
问题 So I have three installers for NVIDIA's CUDA API -- the first is a driver and comes with nice silent install flag options (but you have to be root and have to have run level 3). The second two follow are shown manually installing below (cut out the long mess of install afterwards for brevity) [root]# sh cudatoolkit_4.1.28_linux_64_rhel5.x.run Verifying archive integrity... All good. Uncompressing NVIDIA CUDA......................................................................................

How to return from shell 'read' command passed in expect script?

萝らか妹 提交于 2019-12-24 15:12:19
问题 I am really new to using expect, and a bit confused regarding passing commands to an expect script, so please bear with me... I have searched numerous forums, but cannot seem to find an example of an expect script that uses the read command to get user input. In my Korn shell script, I call an expect script (expectssh.exp) to ssh login to another host and get user input regarding that host's network configuration (network interface card number and subnet mask information). I pass four

expect telnet to multiple cisco devices and execute show run

旧时模样 提交于 2019-12-24 13:52:55
问题 I have the following scripts which is supposed to pull the IP address from a file device-list.txt and then telnet to the device, login and execute a show run. The script logs in to the device successfully, but gives me an error after that. Any ideas where im going wrong? for device in `cat device-list.txt`; do ./test4 $device;done cat test4 #!/usr/bin/expect -f set hostname [lindex $argv 0] set user myusername set pass mypassword set timeout 10 log_file -a ~/results.log send_user "\n" send

How to handle tcl expect output

*爱你&永不变心* 提交于 2019-12-24 13:39:27
问题 I am writing an expect script to telnet to the router ,do some config,expect some output. If the required prompt is not available then it waits for it and gets time out. So how do i have to handle this and print an error msg. set timeout 30; puts "Telnet to $IP 2361\n\n"; spawn telnet $IP 2361; expect ">"; send "ACT-USER::$user_name:1::$password;"; expect ">"; How do i handle and print an error msg if the expected value is not received? 回答1: Dealing with timeouts nicely requires a slightly

Expect Procedure for SSH Login

心不动则不痛 提交于 2019-12-24 12:06:35
问题 I'm new to Expect scripting. I'm trying to create a procedure that will connect to routers/switches over SSH and fall back to telnet if that fails. The code that I have works fine before I put it inside a procedure. I'm sure there's something I'm not understanding about how procedures work. When I call it as a procedure it does connect via SSH which receives "Connection refused" and falls back to telnet like it is supposed to, it just never logs in with the password. When I enable debug mode

iterm2 保存ssh账号自动连接

女生的网名这么多〃 提交于 2019-12-24 10:28:58
作为一名coder,我们经常需要连接服务器进行一些操作,然而冗长的ssh密码登录属实有些繁琐。如果你使用了终端工具iTerm2,便可以事半功倍! iTerm2具有 很多优点 : 智能选中,双击选中,三击选中整行,四击智能选中; 全文查找 command + f ; 窗口垂直 command + d 、水平 command + shift + d 拆分; command + ; 自动补齐命令 记录历史输入命令 command + shift + h 等等。 官网地址 1. expect脚本 首先,我们写一个expect 脚本,放在 /usr/local/bin 目录下, cd /usr/local/bin 创建expect 脚本文件, touch iterm2login.exp vim iterm2login.exp ,编辑脚本内容,内容如下, #!/usr/bin/expect set timeout 30 spawn ssh [lindex $argv 0]@[lindex $argv 1] expect { "(yes/no)?" {send "yes\n";exp_continue} "password:" {send "[lindex $argv 2]\n"} } interact wq 保存退出,然后还有最后一步。 给脚本添加读写权限,在当前目录执行 sudo chmod

TCL / Expect Scripting - Using a conditional statement to attempt a secondary login password

陌路散爱 提交于 2019-12-24 08:55:46
问题 I am very close to finish a TCL/TK app that logs into a Cisco Access Point via a serial connection (RS232} and gives it an IP address (very basic) However, I would like my script to attempt a secondary password if the first one fails This is how the Cisco CLI behaves with a serial connection when the incorrect password is entered 3 times (No User Name is needed, only prompts for a password) Password: Password: Password: % Bad secrets Again, if the default password of "Cisco" does not work, I

SFTP using Expect

房东的猫 提交于 2019-12-24 07:21:00
问题 I have tried the script below to SFTP using bash script. But it does not work. Always error at password. /usr/local/bin/expect <<EOF spawn sftp PG1@dev1.dummy.com expect "Password:" send "abc123\r" expect "sftp>" send "cd /tmp\r" send "get Data.dat\r" send "get List.dat\r" send "bye\r" EOF Here's the log file when I run the script above, after taking in all the suggestions from responders. ######### StartJob ######### Sun Apr 19 09:59:08 MYT 2015 spawn sftp PG1@dev1.dummy.com^M Connecting to

SFTP using Expect

大憨熊 提交于 2019-12-24 07:20:04
问题 I have tried the script below to SFTP using bash script. But it does not work. Always error at password. /usr/local/bin/expect <<EOF spawn sftp PG1@dev1.dummy.com expect "Password:" send "abc123\r" expect "sftp>" send "cd /tmp\r" send "get Data.dat\r" send "get List.dat\r" send "bye\r" EOF Here's the log file when I run the script above, after taking in all the suggestions from responders. ######### StartJob ######### Sun Apr 19 09:59:08 MYT 2015 spawn sftp PG1@dev1.dummy.com^M Connecting to