Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [expect]

The tag has no usage guidance.

1
vote
0answers
33 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 ` ...
0
votes
0answers
61 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 ...
-1
votes
1answer
96 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 ...
0
votes
1answer
40 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 ...
0
votes
1answer
111 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 ...
0
votes
1answer
325 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 ...
1
vote
1answer
241 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 ...
-1
votes
3answers
493 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 ...
0
votes
0answers
49 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 ...
0
votes
1answer
4k 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 ...
2
votes
1answer
2k 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: ...
2
votes
1answer
790 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 ...
0
votes
1answer
52 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 ...
0
votes
1answer
1k 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: #...
2
votes
3answers
16k 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 ...
0
votes
1answer
308 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 ...
1
vote
1answer
42 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 ...
0
votes
4answers
4k 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 '...
1
vote
1answer
1k 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 ...
1
vote
2answers
6k 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 ...
2
votes
2answers
3k 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 ...
0
votes
1answer
903 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 ...
0
votes
0answers
41 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 ...
-1
votes
1answer
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 ...
4
votes
2answers
24k views

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

Update: Working code added here for others CREDITS to : https://serverfault.com/users/30957/glenn-jackman @Glenn I'm sorry! just apologizing and I mean it! Sorry Glenn your code need few changes ...
0
votes
1answer
133 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 ...
0
votes
1answer
417 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 ...
7
votes
1answer
23k 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 ...
3
votes
2answers
1k 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 /...
2
votes
2answers
681 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 ...
1
vote
1answer
2k 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 #!/...
1
vote
2answers
1k 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/...
0
votes
1answer
857 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 ...
0
votes
1answer
1k 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 ...
1
vote
1answer
2k 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 -...
0
votes
2answers
191 views

What could block the output of a command?

Sometimes I'll attempt a (2>&1) redirection and some/all of the resulting output appears to be silenced. e.g. wget -O- http://localhost/test.txt 2>&1 I would expect to see a merge of ...
0
votes
1answer
1k views

expect script + how to perform case in expect script

the following expect script target is to print the hostname name from linux/solaris machine and according to hostname results expect script will run linux.ksh or solaris.ksh script expect_sun_script=`...
0
votes
1answer
1k views

expect script + write “if” in expect script

please advice what's wrong with my exepct syntax ( I run expect in ksh script on Solaris 10 machine ) I want to verify if OS is linux so if it true the expect check if prompt is "#" or ">" and ...
3
votes
2answers
4k views

expect script to support two expected characters

I want to run sshd restart on Linux and Solaris machine via expect ( my expect run in my ksh script ) I create expect script so when expect see the prompt "#" then he run sshd restart but the ...
2
votes
1answer
610 views

kill screen session in an expect script

I start my screen connection with a spawn command within an expect script: spawn screen /dev/... But I don't know how I can kill the screen when the script is finished
5
votes
1answer
3k views

Sending content of a file in Expect

How Can I send the content of a file in Expect? Do I have to use cat command in a way? if yes how? lets say my file is called 1.txt. example: expect "Enter command to send:" {send "???? \r"} ???? -->...
0
votes
2answers
9k views

expect + how to install expect on solaris

subject - install expect on solaris in order to write expect scripts details from my machine: uname -a SunOS 5.10 Generic_139555-08 sun4v sparc SUNW,Netra-T5220 I installed Solaris machine ( ...
1
vote
1answer
601 views

How to listen for SNMP Traps from SNMP enabled network devices?

I just began working for my school's networking department, and I was assigned a project to develop a program to listen for traps from SNMP network devices. The device I am testing with an Access ...
0
votes
2answers
494 views

Httpd + Expect Script Fail (no more ptys) if httpd is not run through cli

I have a CentOS virtual server through Vmware. The server runs an httpd daemon which serves an php page with a form. The users complete the form, and by clicking submit the php page calls an expect ...
5
votes
2answers
3k views

expect + how to identify if expect break because time out?

The target of the following simple expect script is to get the hostname name on the remote machine Sometimes expect script fail to perform ssh to $IP_ADDRESS ( because remote machine not active , etc ...
6
votes
3answers
6k views

SU and Run Command Using Expect

I want to su to another user, using expect, and then run a graphical program as that user. I am using kcalc to test with: #!/usr/bin/expect set timeout 20 spawn su dummy expect "Password:" send "...
1
vote
1answer
14k views

Expect Script, timeouts and error checking

I was hoping to get a little insight into an expect script that I've written. Basically we have this expect script to perform an sftp upload, key authentication is not an option, and sftp is the only ...
0
votes
2answers
2k views

Get unix 'top' command output from Expect script

All, EDIT I want to execute a unix statement in Expect script and get an output without having to include the interact statement.The unix statement outputs rsize value for a process. I haven't ...
5
votes
2answers
10k views

expect script + expect miss the send string + delay issue

I write the active.ksh script (based on expect) in order to login automatically to some Solaris machine and execute the hostname command (login to virtual IP in order to verify which hostname is the ...
1
vote
1answer
395 views

ssh + multiple ssh connection failed

I have 47 Linux client machines and one Solaris server machine (all Linux client machines are red-hat 5.1) all clients perform ssh connection to the server in order to verify if /tmp/generic_error....