Expect script: obtain the exit code of remote command
Hi all,
I'm trying to run the sipp simulator in crontab but after some attempt I came to the conclusion that for some reason this isn't possible (maybe due to sipp interactive nature). This is confirmed by these posts.
Now I'm trying to launch sipp from an expect script that runs in crontab.
What I need is to grab the exit code of sipp to decide if the system is working (exit code == 0) or not (exit code != 0).
I searched all the afternoon trying to make this working but with no luck.
Here is the code I wrote:
This seems to work fine but unfortunately the variable $exit_status gets this value (two rows):
Quote:
echo $?
0
I guess I use the wrong way: I should use the wait() function in expect, something like:
But I can't figure out how to do this.
I didn't found much examples on the net...
Can anyone help, please?
Thanks in advance,
Evan
---------- Post updated 23-09-10 at 10:48 AM ---------- Previous update was 22-09-10 at 06:40 PM ----------
This morning I found out how to get the exit code from the expect script, here is the code:
Now I have another problem: it doesn't work from crontab, I get 127 exit code from the bash script in crotnab that recall the expect ... any ideas?
---------- Post updated at 11:46 AM ---------- Previous update was at 10:48 AM ----------
I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code
TARFILE=${NAME}.tar
TARGZFILE=${NAME}.tar.gz
ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Hi,
I am writing a menu driven program using shell script. THe script will be collecting data by logging into the other servers and bringing back the data to home server to process it and accordingly issue commands. TO automate commands execution , I am using expect script. However I am not able... (5 Replies)
Geeks,
Could you please help me out in my script and identify the missing piece. I need to check/get the exit status of a remote command executed on remote host through script and send out an email when process/processes is/are not running on any/all server(s).
Here's the complete... (5 Replies)
#!/bin/bash
for servers in `cat ~/servers`
do
rosh -l root -n $servers 'if
then
echo $HOSTNAME
else
exit 1
fi'
done
I have few servers in the for loop that is powered off, so whenever I execute my script, it works fine if all the servers are on, but when it tries to execute the script... (1 Reply)
Not able to execute the file in remote host using except utility
I am automating the SFTP keys setp process:
So i created the expect script for controlling the output of shell
below is my main code:
Code:
#!/usr/bin/expect
set fd
set password
close $fd
set df
set app
close $df... (1 Reply)
I have written the following script to update some Debian boxes.
#!/bin/bash
mxg_hosts_file="/etc/mxg/ssh-hosts"
while read line ; do
mxg_host="$(echo ${line} | awk -F":" '{print $1}')"
mxg_port="$(echo ${line} | awk -F":" '{print $2}')"
echo "Connecting and Upgrading... (3 Replies)
All
i am new to linux, and try to have a simple expect script to ssh then telnet to the network equipment, and exit itself. but dont know why i hang at the last $
#!/usr/bin/expect
set timeout 10
set arg
set arg1
spawn ssh -l UserA 1.1.1.1
expect "assword:";
send "PasSwOrD\r";... (1 Reply)
Hi All,
I am using a expect script to run a shell script on remote server, the code is as follows. But the problem is that it executes only first command, and hangs it doesn't run the next commands.
spawn ssh $uid@$host
expect "password:"
send "$password\r"
expect "*\r"
send... (2 Replies)
from my main script, i am calling an expect script. there are a lot of conditions in the Expect script and it can have any exit value based on success or failure of the Expect Script. how can i check the exit status of Expect scritp in the main script. (1 Reply)
Hi to everyone.
How can I get the exit status from a remote command executed with rexec? :eek:
machine A has RedHat Linux 9 and the remote machine B has SCO UNIX.
Code:
rexec -l user -p password host sh /u/files/scripts/seq_cal.sh 2006 08
I want the exit status returned by... (1 Reply)