expect

Tcl Expect with Putty

别等时光非礼了梦想. 提交于 2019-12-11 04:12:31
问题 Trying to achieve a goal of running putty's plink -telnet via Tcl Expect. When i do a regular: plink -telnet 127.1.1.2 i get an output of the process and am able to properly conduct what i have planned. But when i try the same from Tcl Expect: % package require Expect 5.43.2 % exp_internal 1 % spawn plink -telnet 127.1.1.2 -s 16196 % expect -nocase login expect: does "" (spawn_id exp4) match glob pattern "login"? no expect: timed out there is simply no response from the piped process. Tcl:

could not able to spawn(ssh) using expect

混江龙づ霸主 提交于 2019-12-11 04:03:18
问题 while executing $expect filename.exp user pwd ip I got the error could not execute "ssh -l user ip": no such file or directory The contents of filename.exp are this: #!/opt/sfw/bin/expect -D set OMC_Usr [lindex $argv 0] set OMC_Pwd [lindex $argv 1] set OMC_IP [lindex $argv 2] set cmd "ssh -l $OMC_Usr $OMC_IP" spawn $cmd expect "Password:" send "$OMC_Pwd\r" interact help me to proceed Thanks... 回答1: The problem is that spawn needs the command and its arguments passed to it as multiple Tcl

(Tcl/Expect) clear screen after exit

折月煮酒 提交于 2019-12-11 03:26:08
问题 I want to clear the screen (on the local machine) after exiting from my (semi) interactive expect script. Can I do that from within the script? Here's what I tried, that failed. #!/usr/bin/expect -f set env(TERM) vt100 spawn ssh -Y username@domain set user username set pass password #login sequence expect "password: " send "${pass}\r" sleep .5 #some menu commands to enter ERP.... #... #... set CTRLZ \032 set CTRLC \003 set CTRLA \001 #don't time out set timeout -1 interact { -reset $CTRLZ

Expect: how to print every output of a spawned process to the user

走远了吗. 提交于 2019-12-11 03:22:24
问题 I'm trying to write an expect script, part of the commands will be executed as a different user. So i need to spawn an kuu process, then send commands to it after user provided password. But how do I collect the output of those commands and print it to the user who is running the expect scripts? Thanks 回答1: This can be done by using something like the following: proc outputUntilPrompt {} { global expect_out set prompt "ACT:*>*" set output "" while 1 { expect { -re "(\[^\r]*\)\r\n" { append

Powershell - Interact with executable's command line prompts?

て烟熏妆下的殇ゞ 提交于 2019-12-11 02:30:57
问题 I need to automate some tasks against a legacy application. It doesn't have an API, but the vendor offers a .exe I can run to perform various tasks against the application. I can call the .exe from within PowerShell just fine, but after calling it it prompts for the following input: Do you agree to the license: YES User name: myuid Password: SuperSecretPassword` I can run this interactively from the command prompt just fine and manually enter the requested input as prompted, but I need to

How to find if a file exists in expect script

梦想与她 提交于 2019-12-11 02:28:44
问题 I have a statement inside my expect script like this send "sed -i -e 's/$oldport/$newport/' backup.txt\r" expect "$ " However I wish to first check whether the file backup.txt exist and if it does, then edit it. How do I acheive this? Thanks 回答1: Since expect is an extension of Tcl, all Tcl commands are available to use: if {[file exists backup.txt]} { send "sed -i -e 's/$oldport/$newport/' backup.txt\r" expect "$ " } 回答2: Here is a quick approach by using ls set file "backup.txt" send "ls

Using if/else in expect script

别来无恙 提交于 2019-12-10 22:19:53
问题 I recently updated and reformatted my /etc/hosts file and would like to run through every system (roughly 1000) to refresh my known_hosts file. I'm looking at using an expect script to send "yes" to the RSA fingerprint question. Simple enough. However, I know some of these systems are completely new to me and my password has not been set. This creates two possibilities: "yes" is sent to the RSA fingerprint question and I'm logged into the server. I'll then need to send an exit to close the

TCL/Expect - exec - how to execute program with parameters

允我心安 提交于 2019-12-10 21:15:27
问题 I am experimenting with TCL command exec in tclsh and here are my results: % set show_me_dir "ls" ls % exec $show_me_dir VboxSharedFolder % set show_me_dir "ls -la" ls -la % exec $show_me_dir couldn't execute "ls -la": no such file or directory % set show_me_dir {ls -la} ls -la % exec $show_me_dir couldn't execute "ls -la": no such file or directory % ls -la total 141 d---------+ 1 wakatana Domain Users 0 Jan 22 19:12 . d---------+ 1 wakatana Domain Users 0 Apr 16 2014 .. ----------+ 1

If condition for comparing a string in Expect script

痞子三分冷 提交于 2019-12-10 18:38:21
问题 I have a expect script where I want to check uname -a. if the remote server is Linux then I will run few more remote command using expect. If it is Aix then I will run few other set of commands. However I am not able to create the if condition. Can any one please help me? expect <<'EOF' spawn ssh user_name@server "uname -a" set count 0 expect { "password:" { send password\r exp_continue } "Permission denied" { incr count exp_continue } } set strname LINUX set results $expect_out(buffer) if {

“command not found” errors in expect script executed by shell script

◇◆丶佛笑我妖孽 提交于 2019-12-10 17:44:57
问题 I am trying to implement "shell script calling expect script" so that it does not prompt the user for entering ssh password every time. I started with Using a variable's value as password for scp, ssh etc. instead of prompting for user input every time and understood that I should have a .sh file and a .exp file. I have expect installed in my system (running expect -v shows expect version 5.43.0 ). In my upload-to-server.sh file I have cd $SOURCE_PATH/shell ./password.exp $DESTINATION_PATH