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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
72 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>&...
user avatar
  • 629
1 vote
1 answer
245 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 ...
user avatar
0 votes
1 answer
339 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&...
user avatar
0 votes
2 answers
29 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 root@10.1.31.11 expect "password: " send "pass\n" expect "$ " ...
user avatar
0 votes
1 answer
3k 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) ...
user avatar
  • 1,298
0 votes
1 answer
678 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 $...
user avatar
  • 11
0 votes
0 answers
63 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 ...
user avatar
  • 314
0 votes
1 answer
80 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/* ...
user avatar
  • 255
1 vote
1 answer
3k 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. ...
user avatar
0 votes
0 answers
251 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 ...
user avatar
0 votes
0 answers
325 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 ...
user avatar
  • 101
0 votes
1 answer
596 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 ...
user avatar
1 vote
1 answer
442 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 ...
user avatar
0 votes
1 answer
157 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 ...
user avatar
0 votes
1 answer
48 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 ...
user avatar
  • 123
4 votes
1 answer
5k 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 ...
user avatar
  • 2,986
0 votes
1 answer
1k 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 ...
user avatar
  • 2,986
0 votes
1 answer
437 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 ...
user avatar
0 votes
1 answer
2k 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 ...
user avatar
  • 103
1 vote
2 answers
13k 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, **********************************************************...
user avatar
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 ...
user avatar
  • 103
1 vote
1 answer
442 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. ...
user avatar
2 votes
1 answer
1k 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 ...
user avatar
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 ...
user avatar
  • 1,683
1 vote
1 answer
832 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, ...
user avatar
  • 11
2 votes
3 answers
4k 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 ...
user avatar
  • 1,009
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 ...
user avatar
1 vote
1 answer
2k 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 ...
user avatar
0 votes
1 answer
424 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 ...
user avatar
0 votes
0 answers
165 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 ...
user avatar
2 votes
1 answer
11k 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 ...
user avatar
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.
user avatar
  • 1
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} ...
user avatar
0 votes
2 answers
707 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....
user avatar
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 ...
user avatar
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 ...
user avatar
1 vote
1 answer
730 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 ...
user avatar
  • 291
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/...
user avatar
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 #...
user avatar
  • 1,833
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 "*...
user avatar
  • 1,833
2 votes
2 answers
10k 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 ...
user avatar
0 votes
1 answer
969 views

Expect not working using -c arguments

So I have an expect script like this that works: #!/usr/bin/expect spawn scp me@myserver.com:* . expect { password: {send "mypassword"; exp_continue} } Based on the man page for expect, I think I ...
user avatar
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 ...
user avatar
  • 315
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 ...
user avatar
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 ...
user avatar
13 votes
1 answer
108k views

What is the meaning of "spawn" linux shell commands ? (Centos6)

I need to know how to setup a cron job that automatically connects to the remote server and change the directory and get all the files in that directory to local i think i have to use sftp but i saw ...
user avatar
0 votes
1 answer
6k views

Auto log in SSH using expect

I wrote a script to auto login into a remote server. The login data is stored in a database. /usr/bin/expect <<EOD spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no $SSHUser@$SSHHost ...
user avatar
  • 852
1 vote
2 answers
8k views

Installation of Expect on Windows 7 64-bit fails with "not found in the archives"

Downloaded ActiveTcl from http://www.activestate.com/activetcl/downloads/ Installed ActiveTcl at c:/Tcl/ Go to Bin directory in command prompt (Start > Run > cmd > cd c:\Tcl\bin) To install Expect, I ...
user avatar
0 votes
1 answer
3k views

SSH + Sudo + Expect in Bash script: Run command with sudo in remote machine

I am trying to automate the deploy of some .deb packages with an script. I want to execute sudo dpkg -i $myDeb.deb in a list of remote machines I can access with ssh. I've tried to automate the ...
user avatar
  • 117
1 vote
1 answer
2k views

Why doesn't redirect work for scp password input?

I want to copy from remote box with scp, while the fact that each time I have to re-enter password is annoying. So I store my password in plain text and expect the following code should work scp -...
user avatar