The `expect` program runs a TCL script that sends keystrokes or other interactions usually done by a user in certain given conditions.

learn more… | top users | synonyms

1
vote
0answers
10 views

Tcl/Expect: Can't set variable value correctly

Sorry for my English in advance. I'm newbie in Tcl/Expect. I'm trying to get IPSec tunnel details from router. After that fetch lines with IP addresses. So, I have follow code: send "show tunnel ...
1
vote
1answer
26 views

Autoexpect hangs at the end of the script

I have an autoexpect script. I modified it and it works great, however when it finish to run it hangs and I need to do ctrl+C in order to get my terminal [..] 887VA#logout Connection to 10.255.255.1 ...
1
vote
0answers
22 views

Start a subshell then run commands

Say I have a script that is always run from an interactive shell. I would like this script to launch an interactive subshell that is a replica of the parent (i.e., all environment variables, etc. ...
1
vote
2answers
67 views

Cracking root user: Automating logging into root using “su” from nonroot user

I want to write a script that allows me to pass a password to the su command. The reason for this is to automate the process of logging into root from nonroot account. From my basic understanding of ...
3
votes
1answer
22 views

Expect to scp directory does not work when run from post commit

I am trying to implement a post-commit hook on svn which will scp some files from the svn machine to some other backup machine after each commit. I have written the script with expect as follows ...
0
votes
1answer
53 views

set variable in bash script with EXPECT

I have bash script which can login to Cisco switch and shut/noshut any port i have defined in it. what I want is that i can add variable , like i can define port number in command like this ...
2
votes
0answers
59 views

Installing Expect and TCL

I downloaded the source for expect5.45, and am attempting to install it. tclsh is on the system at /usr/bin/tclsh, but I'm not sure if that means the machine also has "tcl" installed? The ...
1
vote
1answer
21 views

Execute a script compiled on a different PC

If I have a compiled expect script, can I run it on a PC with no expect installed?
1
vote
1answer
70 views

Filename expansion for expect script within bash

I have the following bash script with an embedded expect script: #!/bin/bash if [ ! $# == 2 ] then echo "Usage: $0 os_base_version sn_version" exit fi if [ -e ...
0
votes
1answer
59 views

Sending shell script command keystrokes to a remote shell

Is it possible to make the script run when it shifts from normal mode to the interactive mode. #/bash/bin sudo gatttool -b 80:EA:CA:00:00:03 -I # All these commands are typed in interactive mode ...
1
vote
1answer
154 views

Get the output from expect script in a variable

I have an expect script which provides the IP address: #!/bin/expect -f set nodename [lindex $argv 0] spawn virsh console $nodename expect "Escape character is" send "\n" expect "localhost login: " { ...
0
votes
1answer
30 views

Expect script: How to expect a literal * character instead of * as glob or regex character

I have an expect script that spawns a connection to hunspell to check the spelling of a word. Unfortunately, if the word is in the dictionary, hunspell simply sends back a *. How can I tell expect to ...
0
votes
1answer
49 views

Auto-inputing ssh password in shell scripts on Linux [duplicate]

I can use ssh command and provide password and connect to another server. But I need to pass password in the shell script. how?
0
votes
3answers
262 views

How to use expect in Bash script and ssh-copy-id

From a bash script: source ./expect.sh I am including a expect code: #!/bin/bash /usr/bin/expect <<EOL spawn ssh-copy-id -i /home/user/.ssh/id_rsa.pub 111.111.111 expect '*?assword*' send ...
3
votes
1answer
509 views

Calling an expect script in a loop of a bash scrip

I am trying to loop a list of sites through an expect script. The loop will take my list and read it line by line, change directories to the folder of the site name, then pass the site name to an ...
1
vote
3answers
565 views

pass parameters to bash script using chef attributes

I have a bash script ( let's say main.sh ) which I need to integrate with chef. Currently we are using "expect" to pass the parameters to main.sh. Now I need to make script in such a way that the ...
1
vote
1answer
154 views

Get only files modified within last 30 minutes using sftp get

Within a .sh script, I'm using expect to automatically sftp to another computer in order to get files. My script will be set to run every 30 minutes, at which point I want to get only files that were ...
1
vote
0answers
86 views

whether the ssh command successful or not?

I spawned ssh in expect script. in the script i have to check the exit status of ssh command on local machine to make some condition in that script using if/else. spawn ssh user@192.168.1.1 ...
2
votes
1answer
261 views

Expect Script for Command Line

I am writing a script that will allow a Linux admin to quickly change passwords of its users. #!/usr/bin/expect # Check password for strength # ---------------------------------------------- read -p ...
2
votes
1answer
168 views

Huge delay in script response when using SFTP with expect

I am using a script to call SFTP service to fetch some logs from the remote server. This works fine in normal scenario but, i have noticed a very long delay of around 30 minutes or more in some of the ...
0
votes
2answers
193 views

pexpect fails to match command is grater than 65 characters

Issue with pexpect, python module. Pexpect fails to do expected behavior if the length of the command is greater than 65. #!/usr/bin/python import pexpect sshCmd='ssh root@15.186.22.105' ...
0
votes
2answers
193 views

expect: does “” (spawn_id exp70) match glob pattern

I have written an expect script that works perfect for testing passwords on our network until it has looped through my list quite a bit, then the debug output shows that there is nothing to match. ...
1
vote
2answers
481 views

how to continue bash script execution when expect part is finished

I have bash script and inside it part with expect code: #!/bin/bash set -ex funct() { pass3="some_pass" expect -c " spawn su - oracle expect "Password:" send \"$pass3\n\" ...
5
votes
2answers
383 views

scp command behaves differently when used with expect utility

expect -c 'spawn scp -C -o CompressionLevel=9 ~/partFiles/* abc@10.200.4.15:/export/home/abc/; sleep 10; expect password; send "secretPassword\n";interact' throws - ~/partFiles/*: No such file or ...
0
votes
2answers
239 views

Expect Scripts - Reading from Files and Accepting User Input

How can I write an "Expect" script to: iterate over a list of IP addresses and log in to each to perform commands (like in a BASH for loop). Right now I just copy/pasted the few lines that are my ...
1
vote
0answers
272 views

Why the output is not written to log from expect script

I am trying to write the output of the netcat command including the command also to a file by logging into remote servers. But it is not writing. What am I missing ? #!/usr/bin/expect -f set user ...
4
votes
3answers
10k views

spawn - command not found!

I am using Mac OS X 10.9.4, following is my script to copy files from local machine to different host #!/bin/bash #!/usr/bin/expect echo "I will fail if you give junk values!!" echo " " echo "Enter ...
1
vote
1answer
85 views

Automating setup of the SSH tunnel

I need to frequently login to many machines but I can only login to them from a proxy machine or using an SSH tunnel (by tunneling through that proxy machine). The problem is that I cannot use ...
2
votes
1answer
640 views

ssh and run script on remote host and answer expect answer automate

The ssh from server0 to (server1,server2,server3) (no password need to SSH (trust exists between all servers and private key exists on all servers)) but a remote script on server (server1,server2 ...
0
votes
2answers
786 views

Use a script for a telnet session

I have a problem with my script. It seems my password is wrong. #!/usr/bin/expect set ip [lindex $argv 0] spawn telnet $ip set timeout 10 expect "Login:" send "administrator\r" expect "Password:" ...
1
vote
0answers
531 views

bash - expect and variables

I have the followin: while read line; do userinfo=$(echo $line | sed 's/@/,/') IFS=',' read -a address <<< "$userinfo" userid="${address[0]}" domain="${address[1]}" ...
0
votes
1answer
3k views

Expect script buffer output not showing

How can I get the command output from the buffer? Current'y it's just saying "(buffer). Here is my script and debug output: #!/bin/bash -x while read p; do echo $p { /usr/bin/expect -d << ...
2
votes
2answers
573 views

How do I expect 'echo -e “? \c”'?

I'm an absolute newbie to the UNIX world and have been asked to write a script that interacts with another one - but I'm stuck. The script that I interact with echos the following and I need to send a ...
0
votes
1answer
103 views

Expect works fine,but only in foreground why?

I use this script for update my repo slackware(generate asc,txt,etc) http://slackware.org.uk/people/alien/tools/gen_repos_files.sh I have "automated" it with my expect script #!/bin/sh set -e ...
2
votes
3answers
175 views

Extracting time from logs using tcl, expect

I have logs with the following pattern: 1,30.10.2014,07:51:07,0,0,1,12,28,255,3,255,255,255,0,0,0; 2001,30.10.2014,07:51:07,0,0,0,300,5,0,255; I need to extract date and time... for the first line ...
1
vote
2answers
407 views

Expect script: How to handle two processes?

I am using Expect to automate VoIP calls for quality measurements. My script is calling another VoIP client for a given amount of times. Before the calls should be handled, tcpdump should sniff all ...
2
votes
1answer
135 views

Deadlock with yes command

I have a script called setup.sh: . install.sh && . tolinux.sh && . startn.sh && . startm.sh This is install.sh: yes | sudo apt-get update yes | sudo apt-get install ...
1
vote
1answer
61 views

WinRAR installer.rar situation (automating expect install)

I'm writing a script that should set up a server with no user input. Whatsoever. In order to automate installation of some programs, I used expect. However, what can I use to automate expect ...
0
votes
0answers
180 views

Expect script variable matching ruined by a space

I'm trying to automate some operations with the VC systems I administer, and the manufacturer has MANY inconsistencies in their interface. I'm trying to match a system H323 name and device name, ...
1
vote
2answers
2k views

Create a directory if it doesn't exist in TCL

I write expect script that login to remote machine and run there some scripts But I need also to verify the following Verify if directory /var/cti/adm/APP exists. If APP not exists under adm ...
1
vote
1answer
335 views

TCL script try catch

I have a TCL script that sets a number of variables and reads several files. The last file it reads may contain sensitive information, so I need to make sure this file gets deleted even if an error ...
2
votes
0answers
58 views

unbuffer/expect swallows the rcode when its child is signaled

unbuffer is able to pass along the return code of a process under normal circumstance, but if the process you are unbuffering is killed, for instance with a segfault, I see $? as 0 while I expect 139. ...
0
votes
1answer
3k views

How to copy two files in expect script?

please advice why spawn scp $FILE1 $FILE2 $LOGIN@$IP:/tmp in my expect script copy only FILE1 and not copy FILE2 ? I try to to transfer both files by scp as scp file1.csv file2.crt ...
1
vote
2answers
316 views

When using expect: SSHFS Transport endpoint is not connected

When I run my SSHFS connection script from bash, everything works perfectly. However, when I run the same script using the expect utility, I get the following error when I try to access the folder ...
0
votes
0answers
187 views

Set terminal title within expect script

I use zsh as my shell, and I wrote an expect script to automate passing my password to ssh; it works perfectly, exept that the terminal window's title is set to the name of my script. I would like to ...
3
votes
1answer
537 views

how to get exit status from command in expect script

Below is an shell script I have written to automate entering the password for the vpnc command. The expect works fine and vpnc activated automatically after password entered, but I need to get the ...
1
vote
1answer
371 views

Expect script: remove password on private key

I'm trying to remove the password on a private key. Doing it by hand is simple, I run this command and enter the password : openssl rsa <newkey.pem > newkey-no-password.pem I'm trying to do ...
2
votes
1answer
303 views

SSH Command behaves differently in Expect Script

I'm using this command on Server1 ~# ssh root@Server2 /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys to append the contents of Server2's id_rsa.pub to the authorized_keys of Server1. It ...
1
vote
1answer
384 views

How can I return a specific error code at this point in my TCL script?

I have a TCL expect script that runs a scp command for uploading a config file to my DNS server: #!/usr/bin/expect -f set config "~/dnsmasq.conf" spawn /usr/bin/scp "$config" ...
1
vote
1answer
2k views

Shell script to perform telnet session to ser2net

I have setup a xenserver (free) hosting a VM (Debian 7.5). On this xenserver I have attached a serial GSM modem. I have configured xen to run ser2net so I have a serial proxy available. This works ...