Unix - Expect Shell - Syntax for using ifcondition on while loop
I have been working on a expect script on AIX OS. The script should pick the server list from input file from while loop and proceed with an if condition to match a specific pattern then proceed. else...
View ArticleRemove carriage return (\r) from variable in expect script
Setup Ubuntu 16.04 expect Scripts In the simple script bellow the goal is to simply find the oldest .zip file in a directory on a remote machine using ssh. Then use scp to download this file to the...
View Articleexpect: does "" (spawn_id exp70) match glob pattern
I have written an expect script that works perfect for testing passwords on our network until it has looped through my list quite a bit, then the debug output shows that there is nothing to match....
View ArticleCalculating packet loss from ping?
I've got an ESXi VM that does command execution on some 700~ devices on our network. It's using Expect, and due to the age of this equipment they have periods of poor performance. These two don't mix...
View Articleexpect: 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 Article`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...
View ArticleExpect 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...
View ArticleCron to Bash Script to Bash Script to Expect Script
I want to execute a series of Expect scripts. The chain of execution goes like this: Cron job starts a bash script, this wrapper starts ~11 bash scripts in Parallel - each of them call an Expect...
View ArticleHow to automate connecting to multiple network devices, running a command and...
I have to run a command on around 1000 network devices and save the output to a file. In a file I have a list of all the network device names that have to be connected to using SSH. I then have to run...
View ArticleBash program terminates after a few seconds
I have written a small script to download files from an FTP to external drive that is connected to my Raspberry Pi 3B+. I am using rsync to download my files. Here are the scripts: download.sh:...
View ArticleHow to write an "expect" script that checks if the supplied password matches...
I want to change the password on my server. There are four possible passwords that should all be accepted for changing a password on the server. To achieve this I want write an "expect" script which...
View Articlehow to send special characters in expect script?
I'm trying to send special characters (password) which contains #?!k;|C . these password is dynamic and cannot be hardcoded in script. so I'm passing through variable as below $ expect...
View ArticleExpect script connects with ssh but does not run commands
I need to write a script that runs on a PC with Centos 7 and connects to another PC with Centos 7 using ssh, execute a console command, for example "ls -la" and save the output of it to a file to be...
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 ArticleWhen using expect: SSHFS Transport endpoint is not connected
When I run my SSHFS connection script from bash, everything works perfectly. However, when I run the same script using the expect utility, I get the following error when I try to access the folder...
View Articleset 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:...
View Article'expect' not matching server response string
I'm using a bash script to log into a telnet server and execute a number of commands. It looks like: login_and_run.sh #!/bin/bash unset TELNET_USER_NAME_STRING unset TELNET_PASSWORD_STRING unset...
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/python import pexpect sshCmd='ssh root@15.186.22.105'...
View ArticleHow to spawn expect process with complicated syntax?
In expect it is possible to spawn a process like, spawn /usr/bin/sftp "$uri" /home/user/dest Writing it like this makes things really simple, it will be a one liner. However, I am trying to replicate...
View ArticleHow to check whether a given path is a file or directory
I am using the command below in my expect script (in tcl/Tk) for checking whether the entered path is an individual file or directory: set b [exec ./check.sh $file1 | awk -F {=} {{print $1}} ] The...
View Article