Quantcast
Channel: Active questions tagged expect - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 159

Cron to Bash Script to Bash Script to Expect Script

$
0
0

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 script.

All is well until the Expect portion. I have the Parallel portion in the 2nd Bash script spitting out the hostnames for each expect script into a file. The do in fact appear in groups, but the Expect script dies immediately.

I have heard that due to the nature of Cron jobs I need to pass environment variables to the job. I've tried this so far:

48 9 * * * rm /home/admin/.flag && /home/admin/.profile; /home/admin/nodeTest.sh

nodeTest's significant code is:

for i in {1..10}; do
                for chunk in `ls /home/admin/assets/sagLogs/x*`; do
                        cat $chunk | parallel -j 11 -I% --max-args 1 /home/abdmin/oneNode.sh "%"
                        clear
                done
        done

The chunks are 11 hostnames long. They get put into the parallel program to start the Expect script via oneNode - oneNode just translates the hostname to IP and determines which script to run.

This works just fine from the commandline; just the Cron job that's giving me grief. I've read that the interact tcl command causes issues, but I don't use it in my scripts. This is the line that is run in parallel:

timeout 80 sudo expect /home/admin/assets/activeTest $sag $ip &

Update: changed the previous line to:

timeout 80 sudo /usr/bin/expect /home/admin/assets/activeTest $sag $ip &

Update: After inspecting errors from the Expect script, what I'm running into is a lack of imported env variables. The first error occurs because the TERM variable is == unknown:

'unknown': I need something more specific.
    while executing
"exec /usr/bin/clear"
    invoked from within
"puts [exec /usr/bin/clear]"
    (file "/home/admin/assets/activeTest" line 35)

When I dump env from the calling script (oneNode) I can see term is set:

TEMR=vt100

So it's set in the wrapper, but it doesn't get inherited by the expect script. What to do?


Viewing all articles
Browse latest Browse all 159

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>