expect: get error status when spawn command fails
The below is the sample of a script which we execute daily for getting info from the server. For the last couple of days, some server data is missing from the output which is captured on the local...
View ArticleExpect script + automated telnet process between three Linux machines
Is it possible to do the following by expect script? I have Linux server that connected to linux_machine1 and linux_machine1 connected to linux_machine2 My Linux server have access only to...
View ArticleLog 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}" ]...
View Articleexpect 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:...
View ArticleCommand puts in expect doesn't show the message in the order it should
I have a some scripts to automate a process and I want the message about which step I am in it shows in the command window. A piece of code I have is: puts "** Creation of $VMNAME on $HOST begins......
View Articlepexpect fails to match command if greater than 65 characters
Issue with pexpect, python module. Pexpect fails to do expected behavior if the length of the command is greater than 65.#!/usr/bin/pythonimport pexpectsshCmd='ssh root@15.186.22.105'prompt='[root@user...
View ArticleUse a script for a telnet session
I have a problem with my script. It seems my password is wrong.#!/usr/bin/expectset ip [lindex $argv 0]spawn telnet $ipset timeout 10expect "Login:"send "administrator\r"expect "Password:"send...
View Articleexpect freezes after send
I'm trying to automate a Alpine Linux installation using the following script:expect <<- EOF set timeout -1 spawn setup-disk -e -m sys /dev/sda expect { {WARNING: Erase the above disk(s) and...
View ArticleUsing expect to write a bash script
I am trying to write a bash script using expect. This bash script will reside on a remote server, to be executed at a later date/time. I am using expect to read in a large data file, perform some...
View Articlebash script for activeDirectory join; facing issues using expect to bypass...
Will preface here stating that this is poor practice but I have been requested anyway to store the svc-account credential within the script which will live in vRA for VM template.. not my choice, but...
View ArticleShell script with EXPECT and PUT to SFTP server
I'm working on a shell script and I'm trying to send a backup file to a sftp server :remotepath=/backup/expect -c "spawn sftp user@172.11.23.4expect "password:"send "password123\r"expect "sftp>"send...
View Articlebash script error stty: standard input: Inappropriate ioctl for device
I'm using here-documents in a bash script to automate installation and setup where a password is required many times. I enter the password once and the script passes it to the various commands. In most...
View Article--- Article Not Found! ---
*** *** *** RSSing Note: Article is missing! We don't know where we put it!!. *** ***
View Articlehow to send special characters in expect script?
I'm trying to send special characters (password) which contains #?!k;|C .The password is dynamic and cannot be hardcoded in the script, so I'm passing it as variable as shown below$ expect...
View ArticleRunning expect in systemd unit causes sh syntax error
I am trying to automate the process of connecting to my VPN (SonicWall NetExtender) from my Linux machine by using a systemd unit to call an expect script that supplies the login credentials to the VPN...
View Articleadding ansible_python_interpreter to task with expect module fails to get...
I'm writing a task for CentOS7 inventory in which have to go through prompt dialogues, which I think is best candidate for andible's expect module.- name: setup some command become: yes become_user:...
View ArticleHow can I use regex to match the contents by using expect?
I am new to expect for using the regular expression. trying to parse below input stream. How it can be parse with regexp. As CNTXID is incremental."Data" CNTXID = 1 AP = 99 DEF = FALSE CNTXID = 2 AP =...
View ArticleHow do you shut down an expect script in the presence of a complex shell...
I am running zsh inside of tmux with prezto, and a basic expect script is exiting improperly:set timeout -1spawn $env(SHELL)expect -regex ".*"send "echo 'foo'\r"expect -regex ".*foo.*\r"send "^D"expect...
View ArticleExpect works fine,but only in foreground why?
I use this script for update my repo slackware(generate asc,txt,etc)http://slackware.org.uk/people/alien/tools/gen_repos_files.shI have "automated" it with my expect script#!/bin/bashset...
View Articleexpect script terminating early in Dockerfile
I've got an expect script that I need to run in a Dockerfile. However, the script is terminating after all of the input is sent. What's interesting is that docker build is succeeding. Here's my...
View ArticleWaiting until an application is reading (over a TTY)
I'm writing an expect-style program to interact with a command-line application on Linux. Is there any way that my program can know when the application on the other side of the PTY tries to perform a...
View ArticleExpect: print a multi-line string all at once using echo
I have the following section in my code expect code:set command "echo $output"spawn bashexpect "$ "send "$command\r"expect "$command\r\n"Where output is a multi-line string obtained from...
View ArticleWhy does unbuffer -p mangle its input?
$ seq 10 | unbuffer -p od -vtc0000000 1 \n 2 \n 3 \n 4 \n 5 \n 6 \n 7 \n 8 \nWhere did 9 and 10 go?$ printf '\r' | unbuffer -p od -An -w1 -vtc \nWhy was \r changed to \n?$ : | unbuffer -p printf '\n' |...
View ArticleExpect stuck after issuing exit command from application
Normally when in interactive mode, when I type in exit, it displays Disconnected from Virtual Machine 'pick0:LINUX' and then returns to the bash shell prompt.With my expect script, it is stuck on...
View ArticleCorrect way to set PS1 prompt over ssh
I am trying to set the PS1 prompt dynamically on the my remote machine. The idea is that when I will do ssh to the remote machine, I will also send the value which will set as a prompt for that remote...
View Articleexpect script sending password before prompt
I have written a small expect script for automatic ssh to remote server. But sometimes my expect script don't work. Actually it sends password before password prompt. Here is my script#!/usr/bin/expect...
View ArticleShell Script for logging into a ssh server
I tried writing a shell script which can do automatic login into a ssh server using password which is mentioned in the script. I have written the following code:set timeout 30/usr/bin/ssh -p 8484...
View ArticleExiting an Expect Script
I have this expect script, that will log into a host, run a command, return it's contents and exit. What sort of cleanup/proper exiting needs to happen when I've finished running my command? This...
View ArticleAutomate passing JBOSS installer arguments using Expect Command
I have a JBOSS Installer which when run manually it will prompt for input and below is the sample of the execution is as below[sp@sp baseInstaller]$ ./advStart.sh configBuildfile:...
View ArticleHow to use EXPECT in a loop for ssh
Our Linux setup doesn't have keygen configured for passwordless authentication. Hence I am supposed to use only EXPECT for passwordless authentication in a shell script. /usr/bin/expect<<EOF...
View Article
More Pages to Explore .....