Operating System - Linux
1824874 Members
3812 Online
109674 Solutions
New Discussion

expect script - cron and errors..

 
rmueller58
Valued Contributor

expect script - cron and errors..

All,

I have an expect script that I have that uses
scp to move files from one server to another, it is a transactional thing that I put in cron to run every 15 minutes.. I am getting a message in the mailbox:

CRONTAB LINE:
1,14,30,45 * * * * /usr/local/bin/apphire.sh

MAIL MESSAGE:
spawn /usr/local/bin/scp /tmp/*apphire.txt root@205.202.254.91:/tmp
Executing ssh2 failed. Command:' ssh2 -l root -x -a -o passwordprompt %U@%H's password: -o nodelay yes -o authenticationnotify yes -s sftp' System error message:
'No such file or directory'
send: spawn id exp3 not open
while executing
"send "PASSWORD\r""
(file "/usr/local/bin/appput.exp" line 4)

I can run it manually without error.

APPPUT.EXP
# cat appput.exp
###############################################
#!/usr/local/bin/expect
spawn /usr/local/bin/scp /tmp/*apphire.txt user@:/tmp
expect "user@'s password:"
send "PASSWORD\r"
expect "debug: uninitializing event loop"
send "\r"
###############################################
THIS IS THE SCRIPT THAT INITIATES THE PROCESS
NOTE /usr/local/bin/appput.exp Initiate at the end of the script..
APPHIRE.SH
###############################################
# cat apphire.sh
#!/bin/sh
for dst in `cat /pei/peitools/bin/distid.txt`
do
echo $dst
export D="$dst"
export INFORMIXSERVER=pei

sed s/DIST/"$D"/g /usr/local/bin/apphire.template > /tmp/"$D"apphire.sql
sudo -u support /usr/informix/bin/isql "$D"plus < /tmp/"$D"apphire.sql
done
/usr/local/bin/appput.exp



How would I assure myself the file transfer is completing correctly? Again I can run the file manually and get the following output:

# apphire.sh
arl

0 row(s) unloaded.


blr

0 row(s) unloaded.


con

0 row(s) unloaded.


elk

0 row(s) unloaded.


esu

0 row(s) unloaded.


ftc

0 row(s) unloaded.


grt

0 row(s) unloaded.


mps

12 row(s) unloaded.

plk

0 row(s) unloaded.

plv

61 row(s) unloaded.

raa

0 row(s) unloaded.

raf

0 row(s) unloaded.

ral

0 row(s) unloaded.

val

0 row(s) unloaded.

wat

0 row(s) unloaded.

wsf

0 row(s) unloaded.

wst

0 row(s) unloaded.

spawn /usr/local/bin/scp /tmp/*apphire.txt user@:/tmp
user@'s password:
arlapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
blrapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
conapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
elkapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
esuapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
ftcapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
grtapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
mpsapphire.txt | 336B | 0.3 kB/s | TOC: 00:00:01 | 100%
plkapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
plvapphire.txt | 1.4kB | 1.4 kB/s | TOC: 00:00:01 | 100%
raaapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
rafapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
ralapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
valapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
watapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
wsfapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
wstapphire.txt | 0B | 0.0 kB/s | TOC: 00:00:01 | 100%
send: spawn id exp4 not open
while executing
"send "\r"
"
(file "/usr/local/bin/appput.exp" line 6)

Any insights appreciated..

Rex Mueller - Educational Service Unit #3
1 REPLY 1
rmueller58
Valued Contributor

Re: expect script - cron and errors..

moved to sysadmin because of Cron issue