Questions tagged [expect]
Expect is a utility based on TCL. It's primary use is for building automation into interactive environments such as telnet or ssh based terminal environments. It provides the ability to enter commands on a command line and interpret the output.
61
questions
0
votes
0
answers
139
views
How to display output from expect?
I'm trying to read data from a machine that uses a telnet style interface using expect. An interactive telnet session works like this:
% telnet 10.92.177.14 53595
Trying 10.92.177.14...
Connected to ...
7
votes
1
answer
1k
views
Can Expect make sure a certain log does not appear?
Expect scripting is great for writing tests that are basically "make sure that running this command causes these logs to be printed". Expect lets you skip past the irrelevant output and look ...
0
votes
1
answer
107
views
What's the best way to replay keystrokes on to my terminal?
I find myself having to do a series of ssh in order to get to a particular host. What I currently do is to copy and paste the commands into the terminal, one after the another, like a machine. I'm ...
0
votes
1
answer
336
views
expect spawn command: Escaping newline (\n) in string
I am trying to use expect to interact with the MATLAB console. Currently I have:
#!/usr/bin/expect -f
spawn {*}/usr/bin/run.sh matlab -r "fprintf(1, \"The identifier was:%s\\\\n\", \&...
2
votes
1
answer
5k
views
expect -timeout vs. "set timeout" in expect: Different behavior
I was testing a expect script and found two different behaviors when using set timeout vs. expect -timeout. Here is a simple example
response.sh:
#!/usr/bin/bash
sleep 2
echo hello
test1.sh:
#!/usr/...
0
votes
1
answer
692
views
how to use expect into bash to automate installation
I have a bash that answers the questions that freefilesync asks during installation, using expect:
#!/bin/bash
tar -xf FreeFileSync*.tar.gz
mv FreeFileSync*.run FreeFileSync.run >/dev/null 2>&...
1
vote
1
answer
2k
views
passing bash variables to expect script or scripting expect from inside bash
This script is intended to mount the contents of my server at home as a read/writeable drive in mac os. Unfortunately due to the fact that my house has a dynamic public ip address, the ip address of ...
0
votes
1
answer
1k
views
Eternal loop with expect
I want this expect script to run forever (or until "ok" is printed), however it does not and exits right away.
#!/usr/bin/expect
set timeout 180
spawn ssh -o "StrictHostKeyChecking no&...
0
votes
2
answers
472
views
For cycle with expect and variable evaluation
I want to execute a script remotely with expect and a for loop:
#!/usr/bin/expect
set timeout 10
spawn ssh [email protected]
expect "password: "
send "pass\n"
expect "$ "
...
0
votes
1
answer
5k
views
Setting and using a variable within a single-line Expect command in a Bash script
I have an array, $HOSTS, which contains a set of hostnames.
I have a database table that has a set of IP addresses. I want to go through each IP address in that table and send a command (hostname -s) ...
0
votes
1
answer
2k
views
Expect script - sometimes no log generated
I have a simple expect script that supplies password 4 times.
I am logging the output to a log file using
log_file -a /home/applusr/e291505/logs/ADD.log
spawn /home/root/admin/add.mims.user $...
0
votes
0
answers
156
views
Is it possible to detach and re-attach to a spawned process using separate expect processes?
I have an expect script that spawns a process, then does some initialization (authentication), then performs some task that needs prior authentication.
Considering to extend the script to execute ...
0
votes
1
answer
271
views
spawn, expect, send aborts during scp transmission
I have a basic scp sending mechanism with spawn, expect and send.
However it gets aborted during the scp transmission.
Here is the expect command:
expect -c "spawn sh -c {scp -r -P 22 /tmp/rootfs/* ...
1
vote
1
answer
7k
views
How do I get my expect statement to not output the stdout of the first command?
What I'm trying to do is execute an ssh command that prints out the /etc/shadow file. Obviously that file requires root or sudo permission, and I don't have root creds, therefore I have to use sudo. ...
0
votes
0
answers
292
views
Bash automation SFTP script not moving the last file once in a while
I have developed a bash script for moving files to FTP only when a particular CSV is available in remote server. A job from another Data quality tool calls this script. Script is working fine, but it ...
0
votes
0
answers
601
views
Obexctl: Provide different result in terminal and script
I have created a script where I want to send file over bluetooth. For that I took "obexctl" utility. I can transfer file using obexctl utility over terminal. But when I'm trying to incorporate the ...
0
votes
1
answer
1k
views
How to toggle outlet power to Eaton ePDU G3 from shell script
I'm trying to programmatically toggle power to several outlets on a Eaton ePDU G3 using ssh via Jenkins CI shell script. This is to fire up lidars only during a Jenkins run. It is not clear how to do ...
1
vote
1
answer
718
views
TCL/Expect script with if/else logic based on host IP address
So I have been using and enjoying /usr/bin/expect for scripts because it can quickly log me into servers since it autocompletes my userid and password. Through some cursory reading, I've come to ...
0
votes
1
answer
332
views
Using expect to try a series of passwords
I'm completely new to using "expect" and clearly don't understand it at all well. My problem is that I used "encfs" to protect some files a while ago, and although I left myself a text file which ...
0
votes
1
answer
65
views
Expect not exiting non-zero
My real goal is to have a script that will run locally to ssh into a remote server, restart tomcat, and use expect to wait for the "Server startup in" message, or exit non-zero if it sees startup ...
6
votes
1
answer
8k
views
Which characters require escaping in expect strings?
I know that hard brackets [, ] require triple backslash escaping when used inside expect "..." strings, so I use expect "blah blah \\\[herp derp\\\]" to accurately convey these characters to the ...
0
votes
1
answer
2k
views
Does set timeout change each expect statement, or just the final expect eof?
I'm learning to use /usr/bin/expect for the first time, to automate the nightmare that is installing fink from source, as that script has a few dozen prompts, all of which can be answered with the ...
0
votes
1
answer
616
views
how to escape # in my expect scipt while calling password from another file
I have few queries in expect..
I'm using expect script and I need to pick the password from a different file..
1) I'm able to do it.. but for one of my connection the password starts with # (hash ...
1
vote
1
answer
3k
views
How do I send the stdout of a command to an Expect input?
I want to write a shell + expect script that auto-fills my passwords via the LastPass CLI utility lpass. I'm not sure how to accomplish sending the password returned by lpass to the password input in ...
1
vote
2
answers
14k
views
Ansible expect not working for multiple prompt values
I need to install nginx agent for openam using ansible.
while install the nginx_agent it asking multiple question while run the script,
**********************************************************...
0
votes
1
answer
3k
views
Variable expansion and escaping in heredoc syntax
I've got the following script to scrape out the arp table of a switch. No matter how I try to escape everything, quote it or otherwise try I can't get it to work properly. The bash line is interpreted ...
1
vote
1
answer
469
views
Automating SSH login gives unresponsive remote-shell, dropping back to client-terminal (without errors)
I have a problem with the tool expect under Ubuntu 14.04 LTS. I want to automate ssh logins to some Sophos UTM Firewalls and evelate my rights directly after with "sudo su -" and the correct password. ...
2
votes
1
answer
2k
views
How can I set up nautilus to use a ssh connection established by an expect script?
In order to automate a ssh connection, I wrote a script using expect, which works just fine. However, I would like to use this script in the nautilus connect to server function. My idea was to include ...
1
vote
1
answer
2k
views
Expect script for telnet communication with DLink router
I am trying to connect to my router through telnet using this script:
#!/usr/bin/expect -f
set timeout 20
# router user name
set name "admin"
# router password
set pass "admin"
# router IP ...
1
vote
1
answer
941
views
sending GREP command fails
I'm new to expect scripting and trying to get below script to work. The script logs in to a server and reads a config file ($val in the script) for the values of "cps" and then presents a total value, ...
4
votes
3
answers
8k
views
Automating an ssh connection with crontab
I've been struggling to crontab automate a git push process with ssh, and it's proving tricky to setup a key with the ssh agent. Starting with a basic script to test the agent:
# set paths (all ...
0
votes
1
answer
3k
views
How to handle a condition when an expect script executing another script on a remote host is interrupted?
Im using an expect script to say xyz.exp to login to a remote host and execute another script abc.sh
Now most of the times abc.sh runs fine, but there is a scenario where if a certain condition is ...
1
vote
1
answer
3k
views
file exists not working in expect script
I'm trying to check if a particular line exists in filename on a host. So only if the particular pattern is found from the grep command a dummy.txt will be created. Then I want to check if dummy.txt ...
0
votes
1
answer
440
views
Bash function only works when password manually input
At work I have to run the following function everyday. The function works fine when I am prompted for the password. However, I tried to hardcode my password so that I don't have to enter it in each ...
0
votes
0
answers
173
views
Simple Expect program to send a key when the program yields some text
I need to run this program:
Luis@Windu /cygdrive/c/Temporal/Expect$ oclhashcat64 ../Test.hccap -m 2500 -a 3 ?d?d?d?d?d?d?d?d
oclHashcat v1.31 starting...
Device #1: Bonaire, 1024MB, 1050Mhz, 12MCU
...
2
votes
1
answer
17k
views
expect + how to verify if dir exists and if not how to create it
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 ...
0
votes
1
answer
1k
views
How do I build a script shell to send cmd via telnet and log only results?
I would like to make a shell script that can call a range of IPs via telnet, to send a command, and write the result to a file.
1
vote
1
answer
2k
views
Timeout does not work in expect script
I created the following expect script in order to automate logging into a VPN:
#!/usr/bin/expect
set PASS [lindex $argv 0]
set timeout 10
spawn vpnc
expect : {send $PASS\r}
...
0
votes
2
answers
799
views
Not able to copy a file via script from local host to remote host
I am trying to write a script that can copy a file from local host to remote host. And then i want to execute that script from local host. But I am not able to copy. I googled and found the below code....
0
votes
1
answer
2k
views
Trying to reboot ADSL modem via expect script
I'm trying to create a Linux script which can reboot my ASDL Modem.
Here is my rebootModem.exp file :
#!/usr/bin/expect
set userName admin
set pass admin
set command reboot #It is modem reboot ...
0
votes
1
answer
2k
views
Using EXPECT script with a $ in the password
I'm trying to set a variable in a Linux bash script which includes a $ symbol, i.e. password is Gl@d1us$123 so PASS="Gl@d1us\$123". I can preceed the $ with a \ and it works fine, but when it calls ...
1
vote
1
answer
880
views
Unbuffer swallows the exit status of killed process
The expect "unbuffer" command seems to swallow the exit status of its child if the process is killed. Is there something that can be done to stop this behavior? It does not swallow the exit status if ...
2
votes
1
answer
7k
views
expect command in ubuntu
I've searched all over SuperUser, but couldn't get the solution.
Here is a script that am using for ssh using expect. I'm using ubuntu and I've installed expect using aptitude install expect.
#!/usr/...
0
votes
3
answers
4k
views
Linux: ssh command works outside bash script, but not within script?
I am having problem with the following command:
echo "Pass for router:"
read -s pass
/usr/bin/expect - << EXPCT
spawn ssh 192.168.10.1 -l root 'opkg list-installed' > list-installed.txt
#...
0
votes
1
answer
8k
views
Problems using EXPECT is a BASH shell script
This is the code (bash script):
echo "Pass for router:"
read -s pass
/usr/bin/expect <<EOD
spawn ssh 192.168.10.1 -l root 'opkg list-installed' > list-installed.txt
#echo @pass
expect "*...
2
votes
2
answers
12k
views
couldn't execute "mysql": no such file or directory, using autoexpect
I have the following file: exp.exp
#!/usr/bin/expect
db_host='localhost'
db_name='webui_dev'
db_user='root'
db_pass='rootpass'
new_db_name='db_2011'
expect <<EOF
log_user 0
spawn mysql -h ...
0
votes
1
answer
996
views
Expect not working using -c arguments
So I have an expect script like this that works:
#!/usr/bin/expect
spawn scp [email protected]:* .
expect {
password: {send "mypassword"; exp_continue}
}
Based on the man page for expect, I think I ...
1
vote
1
answer
2k
views
Expect and sudo timeout
I have a main shell script that prompts the user for his password. I then would like to call an expect script while passing the password to it. This expect script will run 3 sudo commands.
I know the ...
2
votes
2
answers
2k
views
Bash/expect script to log in via ssh and port knocking. SSH Keys not possible
My login server is behind a firewall that uses port knocking to allow entry.
The login-flow is
Enter in port knocking command. This requires my external IP to be entered.
When prompted, enter in my ...
0
votes
3
answers
16k
views
how to run a local script in remote server using expect and bash script
I want to make a script that will connect to a server and do some CRUD operation on the server and again return to local. I do not want to upload the script to server..
I have made a script that ...