Questions tagged [expect]

Expect is a Unix/Linux extension for the Tcl scripting language. It was designed as an automation and testing tool and it makes it trivial to interact with complex programs, such as remote shells, security maintenance. It has particularly powerful response recognition.

Filter by
Sorted by
Tagged with
2
votes
0answers
85 views

Using lpass to unlock an ssh key

I'm using the Lastpass CLI (lpass) and want to have it give the passphrase for a private key direct to add-ssh on login as part of .bashrc . the net effect is that I login to Lastpass on when I start ...
0
votes
1answer
502 views

TCL Expect Not Writing To Output Buffer

I have noticed that my TCL/Expect Script is not writing to the Output Buffer. `#!/usr/bin/expect -f exp_internal 1; #Debug Expect set username [lindex $argv 0]; #Takes Outside Argument set password ...
0
votes
0answers
4k views

“Invalid command name ” while executing, Expect error

I'm getting an error that says: invalid command name " while executing ""\r"" invoked from within "expect { -ex "--More--" {send -- " "; exp_continue} "*>" {send "exit \r";"\r"} }...
0
votes
1answer
55 views

Awk script only works if i edit the text file manually

I'm using awk to organize the information in a text file (It contains CDP neighbors information of a switch taken from terminal) , the file looks like this: Device ID Local Intrfce BIOTERIO Gig 1/0/6 ...
1
vote
1answer
4k views

Expect script to automatically log in, command and show its output

I'm new to scripting and need some help. I am creating an expect script that from a Linux server, that will automatically ssh/log in to our HP StoreOnce Appliance #!/usr/bin/expect -f set password "...
1
vote
1answer
342 views

Need Modifications in my expect script

I have an expect script which performs an SSH to a list of servers with the credentials mentioned in the script. It is not throwing any error when it is unable to SSH to a particular server and ...
2
votes
1answer
520 views

Restrict `expect` to stdin/stdout interaction only

I need to accept job files from users, which would essentially consist of console interaction with a process I will be running for them. Naturally, the first idea that came to mind is to use expect ...
3
votes
2answers
2k views

How can I get `expect` to ignore $ (dollar sign) in a password?

I'm running an expect script and the password has a $ character. The shell looks for the following characters to expand into something and spits out no such variable. Is there any way around this?
1
vote
0answers
384 views

Extract contents of jar file to curl using scp

I have a jar file containing a javadoc tree on one box. I need to transfer it to another box and unpack the jar in a specific directory (which may not exist). I have the username/password of the ...
0
votes
1answer
706 views

expect script to autofill password [duplicate]

Im struggling with how to do things. My goal is that when in on my jumphost type ssh router1, then it will ssh to the router, and at the same time run an expect script to fill in my password from a ...
3
votes
1answer
3k views

Using expect script to automate password checking for a multitude of routers

The task at hand is to check the passwords of a multitude of routers and change it in case any password is still set to default that is, (for .eg) Login: ABC , Password: ABC. I've written an expect ...
1
vote
1answer
4k views

Expect command with multiple commands

Since I have issues with my remote server [authorized_keys...] I wrote a script on my local machine that uses expect command to ssh into the server and then perform cd and then git pull But I can't ...
1
vote
0answers
874 views

Expect script seems to ignore prompt (RSA fingerprint confirmation)

The following script seems to simply ignore the rsa fingerprint/continue connecting prompt. I have tried different things, but I simply cannot figure out why it is not working as expected. #!/usr/bin/...
1
vote
2answers
2k views

expect script for getting output for multiple servers

I am trying to get output of IQN from multiple servers. I am getting the below error. Error output spawn /usr/bin/ssh VM2 | /usr/bin/cat /etc/iscsi/initiatorname.iscsi root@VM2's password: bash: -c: ...
1
vote
2answers
5k views

Expect script for copying file

I am trying to move/copy some files from my local machine to another host which I am able to access via ssh. But unfortunately this below script is not working. when I run this script it is asking me ...
0
votes
1answer
1k views

How to use EXPECT in a loop foor ssh

Our Linux setup doesn't have keygen configured for password less authentication. Hence I am supposed to use only EXPECT for password less authentication in a shell script. /usr/bin/expect<<...
1
vote
1answer
1k views

save expect buffer outside scope?

In my expect script I am using exp_continue to send the spacebar until I get a different prompt, however it appears the way I'm doing it might be putting the $expect_out(buffer) outside of the scope ...
2
votes
1answer
602 views

Expect Script: Maximum number of command line arguments

I am trying to spawn scp command to copy one file from one server to another server. So, I am passing 8 arguments to an expect script as follows expect my_x_script.exp file_src file_dest s_user ...
0
votes
1answer
261 views

Backup Cisco with expect

I was setting to backup the running config but carried out not do as I like, how I can dump the data in txt? #!/usr/bin/expect -f set force_conservative 0 ;# set to 1 to force conservative mode ...
1
vote
1answer
1k views

TCL Script - expect when scp is done

I currently have a tcl script that is sending a .tar.gz to a remote server. spawn scp -r "file_to_send.tar.gz" $user@$host:/ set timeout 10 spawn ssh $user@$host expect "password: " send -- "$passwd\...
1
vote
1answer
4k views

How to automatically add keyfile and passphrase to ssh-agent?

Linux 4.4.0-34-generic #53-Ubuntu SMP Wed Jul 27 16:06:39 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux I use the script to start ssh-agent and start other script (which is using expect to sent passphrase ...
3
votes
1answer
766 views

Why does a gdb client fail to talk to its gdb server when started by this “expect” script?

I'm building a continuous integration environment for a firmware codebase, programming an ARM Cortex M0 using a Segger JLink device and running tests on the target using gdb and Segger's RTT tool. I ...
2
votes
2answers
7k views

spawn command issue in Expect Script

I am using KALI Linux and have some trouble with an expect script. I don't know why the spawn command doesn't perform any action, it just echos out the same text #!/usr/bin/expect -f spawn apt-get ...
1
vote
1answer
6k views

Capture stdout from ssh session to local machine

I am having to put together a script that will ssh into devices to run a command such as "show running-config" and save the output to a file on my local machine. I have done similar tasks like this ...
1
vote
1answer
1k views

`Interact` not working as expected in bash/expect scripting

In order to provision an embedded device (i.e. writing images to flash) a series of very well known commands have to be entered during the boot stage. The algorithm is something like: Capture a ...
3
votes
2answers
4k views

Log the output of Expect command

I have made the below expect script and I need to log the output of that script. SOURCE_FILE=`ls -l *.txt --time-style=+%D | grep ${DT} | grep -v '^d' | awk '{print $NF}' ` if [ -n "${SOURCE_FILE}" ] ...
0
votes
1answer
135 views

Expect Script - bash script file not found [closed]

My expect script #!/usr/bin/expect -f #I tried replacing sh - with bash -s still no positive results spawn ssh xxxx@yyyy "sh -" < test.sh expect "password: " send "zzzzz\r" expect "$ " This ...
0
votes
1answer
2k views

Expect Rsync with Double quotes

Below is my code: #!/usr/bin/expect -f set timeout -1 spawn rsync -arvz -e 'ssh -p 1690' --protect-args --progress /home/pappu/ 'backup@xx.xx.xx.xx:/volume1/56 - Backup Server/pappu' expect "password:...
1
vote
1answer
1k views

script ssh login to server and pass root password

I have written an expect script to automate the login process for ssh. My user account has rsa keys setup but once I log in I want to switch to root but the remote server is hanging on the password. I ...
1
vote
2answers
6k views

How to write expect in shell

This is continuation to my previous question :Spawn command not found After referring to few old posts, I have written those commands, If its wrong, then how I can run ssh to remote server and run ...
1
vote
1answer
5k views

Spawn command not found

I trying to use the spawn command to connect to remote server, execute some commands/script. Here is script: #!/usr/bin/expect for i in `srvctl status database -d PROD | awk -F " " '{print $(NF)}'` ...
0
votes
1answer
368 views

login to remote server using expect program

I have written an expect program (refer below:), where I am trying to copy files to remote machine. While scp'ing, if I provide wrong password, my expectation is second condition will be met and print ...
1
vote
1answer
1k views

Send command to already running process in shell script

In bash how can I issue a command to a running process I just started? For example; # Start Bluez gatttool then Connect to bluetooth device gatttool -b $MAC -I connect # send 'connect' to the ...
0
votes
2answers
10k views

Unable to execute bash script inside expect script

i have a expect script like #!/usr/bin/expect ..... spawn passwd expect "password:" send "password" .... .... .... ~/test.sh Wile executing this, I'm unable to run bash script test.sh. How to ...
1
vote
0answers
15 views

Configuring an alert when a program tries to interact with the user

Most programs in *nix-land take their options via the command line or through a configuration file. However, there are a few programs that do not have any such option, and will resort to interacting ...
0
votes
2answers
797 views

Bash using netcat, send one command's output to file

I need to know how to grab output and store it in a variable. I don't want to send all the output to the file, just one of the commands output I am sending.. Basically AUTH AUTH LIST <---needs to ...
1
vote
2answers
2k views

Using special character " and ` in send command in expect script

I am trying to execute a command in Linux servers to fetch which all servers requires root password reset as there are multiple servers I am using an expect script to automate it , my command contains ...
0
votes
2answers
900 views

Can I have a (bash) shell with expect running in the background?

I am trying to write an expect script that once started will watch my terminal and run a command every time that it finds a match. Is this even possible with expect? If so, would expect_background ...
2
votes
1answer
1k views

Expect PECL for PHP 7

I just upgraded to PHP 7.0.3, but there is no support for expect. Does anyone know if is it possible to bypass the installation issue? It says: root@portal:/home# pecl install expect-0.3.3.tgz pecl/...
11
votes
1answer
7k views

Can I build a Docker container from Dockerfile in an interactive way with allocation of some pseudo TTY?

I build container from below Dockerfile: FROM ubuntu:14.04 ... RUN apt-get update && apt-get install -y vim #RUN ssh-keygen -f /root/.ssh/id_rsa -N strongpass123$%^ RUN ssh-keygen -f /root/....
2
votes
0answers
288 views

Tcl/Expect: Can't set variable value correctly

I'm trying to get IPSec tunnel details from the router. After that fetch lines with IP addresses. So, I have follow code: send "show tunnel ipsec remote 10.10.10.10\r" expect "local" send "\r" set ...
1
vote
1answer
1k 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
294 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
1k 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
409 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
6k views

set variable in bash script with EXPECT

I have a 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 a command like this: ./...
2
votes
0answers
1k 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
33 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
894 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 /some/file/path/$...
0
votes
3answers
797 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 ...