Questions tagged [expect]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
57 views

Continue statement doesn't work as it should - bash

For the context, i have an infrastructure of multiple machines using ssh. We connect via ssh as root on the machines without password thank's to the authorized_keys file on each mchine. We are adding ...
user avatar
1 vote
1 answer
91 views

Using expect to automate Alpine Linux installation in FreeBSD in Bhyve

I am attempting to automate installation of Alpine Linux in vm-bhyve under FreeBSD and expect dies shortly after the boot menu times out and launches the Alpine Linux installation. #!/usr/bin/env ...
user avatar
  • 243
0 votes
1 answer
42 views

Restart services on multiple remote servers securely

I need to write a script so that my colleagues and myself can restart different services on multiple servers. We all connect to the servers with LDAP so i'd like my script to connect our LDAP users to ...
user avatar
  • 91
1 vote
1 answer
2k views

using ansible --ask-become-pass in a variable

I would need to use my --ask-become-pass password in an expect script. Is there any way to use the password entered when starting ansible_playbook in a variable? Pseudo-code: # ansible-playbook --...
user avatar
  • 101
0 votes
0 answers
107 views

ansible.builtin.expect to automate an installation and having to go thru a license agreement

I am trying to use ansible.builtin.expect to automate an installer. At the beginning of the install, I have to "read" thru the license agreement by hitting the space bar 7 or 8 times. I do ...
user avatar
  • 41
0 votes
0 answers
79 views

on expect: need to spawn a python script that fetches a string and send it back

The first script is basically an external lib that I don't want to tamper with. I already tried the following: set timeout 100 spawn python long-running-script-with-prompt.py expect "Type the 6 ...
user avatar
0 votes
0 answers
57 views

Bash to expect script to add user

Need help Required to convert below bash script in expect script. #Script to Add User tail /etc/passwd | cut -d: -f1 read -p 'Please Enter The Username To Add: ' name echo "$name" > /tmp/...
user avatar
  • 19
0 votes
1 answer
88 views

Trim and allign an output of command in expect script

{ echo ' ' ;echo ' IP : ' ;ip route get 8.8.8.8 | cut -d' ' -f7,8 | tr -d 'src' ;echo ' ' ;dmidecode -t bios | grep -iw 'Version' ;echo ' ' ;} the output of above command mentioned is: IP : 10.0.0.1 ...
user avatar
  • 19
0 votes
1 answer
461 views

how to use ping in expect script

Need assistance while i want to ping server if got reply then proceed with script and if no reply go again to previous step where we fetch IP from hosts.txt #Setting up Variables set timeout 5 ...
user avatar
  • 19
0 votes
0 answers
156 views

Expect Script: First ping the IP stored in hosts.txt file and if got response of ping run script

for below code i want to check if the IP is up via ping and if ip is up run below code eles check next ip from hosts.txt Edit 2: FYI ill be running script from windows machine Edit 3:I managed to ...
user avatar
  • 19
1 vote
1 answer
707 views

Merging Expect script and Bash script

This is my expect script for login into a remote server.where i ask user to put password. #!/usr/bin/expect -f #Grabbing Password to be used in script further stty -echo send_user -- "Enter the ...
user avatar
  • 19
0 votes
1 answer
852 views

shell scripting with expect and a complex command line: no such file or directory

I'm trying to make this work #!/usr/bin/expect spawn "(psql blabla \"blabla sql;\" &> /dev/null) && (pg_restore -d xx my_file.sql &> /dev/null)" expect "Password for user ...
user avatar
0 votes
0 answers
121 views

I would like to automate the ssh login to an AIX server that hs

I would like to automate the login to an AIX server. I dont have a way to set up ssh keys im on mac so i cant install ssh pass so my only option left would be expect. #!/usr/bin/expect -f set ...
user avatar
3 votes
2 answers
2k views

How to detect timeouts in an expect script

Consider an expect script that spawns a command and waits for a sequence of events. We use this to test software. I'm trying to always get a failure return value from the script when there is a ...
user avatar
1 vote
0 answers
129 views

expect, mpd5 and dynamic config loading

I have a FreeBSD server that's connected to WAN using PPPoE. Iva esuccessfully set ip the L2TP and PPTP VPN ontop of this PPPoE WAN connection. The problem is that L2TP needs to call 'set lt2p self ` ...
user avatar
  • 8,004
0 votes
0 answers
558 views

Ansible expect does not pass response to kibana keystore

Ansible expect is not passing ansible variable on first pass. If I make changes and re run the script adding an additional response question then the script seems to work but if I just want to set ...
user avatar
  • 21
-1 votes
1 answer
598 views

kpcli bash script to automate entries

I am trying to create a bash script which uses kpcli in order to automate entries into a kdbx file. While searching over here I found out that you could use expect and send, however this does not ...
user avatar
1 vote
1 answer
479 views

Expect Scripting: Is there a way to default back to a previous spawn_id?

After I scp a file using spawn, the spawn_id, exp8, closes out. gets eof. so, any other commands I run after that, I get this message: an not find channel named "exp8". So I'm assuming that once a ...
user avatar
  • 13
0 votes
1 answer
242 views

Forwarding access to mysql via ssh tunnel with the help of expect

I have this command that creates a working ssh tunnel for access to MySQL server: ssh -f test@remotehost -L 127.0.0.1:3306:mysqlhost:3306 -N Here, remotehost is accessible only via jump host which ...
user avatar
7 votes
1 answer
6k views

How to get installed unbuffer on centos?

$ unbuffer -bash: unbuffer: command not found Centos 7.x How to install it by using yum? yum install unbuffer doesn't work.
user avatar
  • 859
0 votes
1 answer
1k views

How to use SFTP BatchMode inside EXPECT[Shell Script]

I have set of series SFTP commands which needs to run inside expect. But when i run the below script due to some reasons am not getting any output. Please correct me if am wrong any where inside the ...
user avatar
  • 3
1 vote
1 answer
377 views

Expect doesn't recognize output on Cisco router

I'm writing a script with expect to configure cisco routers automatically via ssh. A part of this script is to copy an image into flash if it doesn't exist: For this expect sends a copy and waits for ...
user avatar
-1 votes
3 answers
2k views

Linux + how to run the ssh-keygen interactive from bash script [closed]

Please advice how to generate the file id_rsa.pub without answering the questions from "ssh-keygen -t rsa" my target is to run the ssh-keygen from bash script from postgress USER, and it must run ...
user avatar
  • 451
0 votes
0 answers
136 views

Expect is prompting password twice while spawn

spawn ssh -q user@xx.xx.xx.xx Password: Password: Expect is expecting null before I sent the password. Debug info expect: does "" (spawn_id exp6) match glob pattern "yes/no"? no "Password: "? no ...
user avatar
0 votes
1 answer
7k views

Ansible expect not passing response

I am trying to use Ansible with the expect module to join a linux server to a active directory with sssd. code from the task: - name: join domain expect: command: /bin/bash -c "/usr/sbin/realm ...
user avatar
2 votes
1 answer
3k views

Ansible "expect" module with sudo?

I want to run an installer script with Ansible. The installer script prompts for a number of responses and requires to be run with root privileges. Here is the essence of my Ansible task: - expect: ...
user avatar
  • 153
2 votes
1 answer
1k views

How to use wget in an Expect script?

I first download a file to /root/TRY1/: #!/usr/bin/expect cd /root/TRY1/ exec wget --http-user $user --http-password $password $url Then I want to extract the file: cd /root/TRY1/ exec bash -c "tar ...
user avatar
0 votes
1 answer
57 views

Same script, same OS, same installation, failing

So I'm working with RANCID to monitor some switches and I'm using clogin now to test some modifications. I'm working in two different computers but both of them from the office. Althought they are ...
user avatar
  • 1,327
0 votes
1 answer
2k views

Expect Scripting Issue Reading From File

I am trying to change the password for a user on a bunch of linux based routers pulling IPs from a list. The iplist.txt is just a list of ips (one per line). This is the code I am trying to use: #...
user avatar
5 votes
3 answers
43k views

Expect script too fast: add a sleep between each line read from a file

I am trying to automate switch commands. It's almost all good, but when the expect script reads each line from the file containing my switch commands (listed line by line), the switch seems to stop ...
user avatar
0 votes
1 answer
487 views

SSH to ESXi server with Expect immediately closes

I am writing a VM deployment tool that needed to start VMs on an ESXi server. To do this I am using Perl's Expect module to spawn an ssh client to connect to the server and use vim-cmd to manage the ...
user avatar
  • 245
1 vote
1 answer
48 views

SFTP script gets different destination response when run from different directories

I'm baffled by an SFTP shell script and any help would be greatly appreciated. I wrote an sftp script to connect to and upload ACH information to a banking site. The script uses 'expect' to wait for ...
user avatar
  • 21
0 votes
4 answers
9k 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 '...
user avatar
  • 473
1 vote
1 answer
2k views

expect script running screen stops working when run by cron

I hope this question is OK for this forum. I have a device, a modem. I talk to this modem with the linux program "screen" as a terminal program. I invoke it like this "/usr/bin/screen /dev/tty6". I ...
user avatar
  • 139
1 vote
2 answers
11k views

#!/usr/bin/expect not working

This is probably an easy question, however have a simple expect script that I've add the executable bit to that seems to be ignoring the #!/usr/bin/expect interpreter line. Further more, it also ...
user avatar
  • 978
2 votes
3 answers
4k views

password check in bash script calling on expect

Background: I have to copy a file from one server, to over 100 servers in a test environment. once the file is copied, it requires to have the permissions on the file changed/verified. These are all ...
user avatar
0 votes
1 answer
1k views

catch bash script output from expect, expect hangs

I currently use expect to pass password to rsync to copy files across unix servers test.sh ./expect.sh $password rsync -azvr $username@$host:$file ./$dir expect.sh #!/usr/bin/expect -f ...
user avatar
  • 1,075
0 votes
0 answers
49 views

less doesn't work in LXC container

I'm experiencing some trouble running less and expect inside LXC container (whether using console or SSH) Expect won't work before I won't add an "interact" anywhere in the script, and less doesn't ...
user avatar
  • 1
0 votes
1 answer
2k views

Bash Script - Expect does not send password that ends with $!. Also need improvement to report connection timed out

Update: Password issue is fixed and connection timed out message was fixed too. Adding \ before $! worked. Example: *password\$! set passwds { *password\$! @tempP@ss %Test4%} For connection timed ...
user avatar
  • 81
7 votes
2 answers
35k views

Expect script error send: Spawn id exp4 not open while executing

I'm trying to run this script but having different errors when modified. Here is the code and the output. Please help. Updates at the end of the post with debug info #!/bin/bash (( $# != 1 )...
user avatar
0 votes
1 answer
140 views

How to distribute root files with expect?

I've recently learned how great expect is, now that I'm suddenly responsible for managing 150 VMs. I've been using it to distribute config files to remote servers, but there's got to be a better way ...
user avatar
  • 1,471
0 votes
1 answer
551 views

SELinux problems running Expect script from fail2ban

I have an Expect script that works fine if I run it manually, but fails when run as an action from Fail2ban. The error message is as follows: spawn /usr/bin/telnet 192.168.242.1 The system has no ...
user avatar
  • 882
8 votes
1 answer
27k views

Ansible ssh as user and execute has root (expect like)

I have to administer an important number of hosts where there is only one user able to access from SSH (let's call him foo) and then have to login as root to execute privilegied commands. Foo user ...
user avatar
  • 173
5 votes
2 answers
3k views

How to keep script from swallowing all of stdin?

I have a script that reads from a pipe in a loop and runs an expect script and a normal shell script in the loop. Both scripts run ssh to another server to grab a piece of data. For example: cat /...
user avatar
  • 51
2 votes
2 answers
900 views

Router config export via expect script - username in enable?

I'm working on an Expect script for pulling configuration information from my hosts. The problem is that some of my hosts (when the enable command is entered) will prompt for both a login and ...
user avatar
  • 15.4k
1 vote
1 answer
3k views

expect: how to use expect scripts from within a bash subroutine

I want to write a login script in expect. But I want this to be reused in different other scripts. I want to make all the login commands part of a bash subroutine. ie instead of expect_login.sh #!/...
user avatar
1 vote
2 answers
2k views

Error while installing php extension 'expect'

I got some serious error while installing expect extension in PHP. I ran sudo pecl install channel://pecl.php.net/expect-0.3.1 I got error like this while running make, running: make /bin/bash /tmp/...
user avatar
0 votes
1 answer
2k views

expect script works fine standalone not from bash script

I am running a expect script,which login to a server check if iptables running and return the log file of the status. There is a hostfile also given with server list and password, expect is being ...
user avatar
0 votes
1 answer
2k views

screen, expect and scripted detached interaction

Trying to write a bash script which will open a screen, start a python application, and interact with the python interaction as required when it is first started. If not possible in screen, I would ...
user avatar
1 vote
1 answer
4k views

expect script not working with bash script

I want a script that ssh to remote server and then run a script which is at my local machine and then store the output on my local machine Expect script for ssh to remote server: #!/usr/bin/expect -...
user avatar
  • 11