Running EXPECT script through cron 
Author Message
 Running EXPECT script through cron

I hope there aren't too many objections to posting an EXPECT question here. If there
is a more appropriate place, I'm all ears.

I have a script that runs fine when I execute it as root. When I run it via cron
I don't get all the output. Any ideas?

script follows:

#!/usr/local/bin/expect -f

    log_user 1
    log_file -a /cisco/cisco.tmp
    spawn telnet cisco_router
    expect "Password:"; send "******\r"
    expect "cisco>"; send "show users\r"
    interact timeout 5 {
       send "quit\r"
    }

When this script is run as root the logfile /cisco/cisco.tmp contains:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
spawn telnet cisco_router
Trying...
Connected to cisco_router
Escape character is '^]'.

User Access Verification

Password:
cisco>show users
    Line     User      Host(s)               Idle Location
* 10 vty 0             idle                     0 APOLLO.ECTE.USWC.USWEST.COM

cisco>quit
Connection closed by foreign host.

When the script is run by cron the logfile /cisco/cisco.tmp contains:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
spawn telnet cisco_router
Trying...
Connected to cisco_router
Escape character is '^]'.

User Access Verification

Password:
cisco>

As you see, the very data I'm searching for is missing from the file.

I saw in the book that there were some peculiarities about the cron environment
but I didn't see the solution to my problem.

Any help would be appreciated.

Thanks in advance!

--
Tom Stirrat
US West Technologies
Software Configuration Management



Sat, 01 Aug 1998 03:00:00 GMT  
 Running EXPECT script through cron

Quote:

>As you see, the very data I'm searching for is missing from the file.

>I saw in the book that there were some peculiarities about the cron environment
>but I didn't see the solution to my problem.

Hmmm, what does interact do when expect has no controlling terminal?
It looks like you're relying on the interact to pull in the data, but
it might be aborting early when run under cron.  Maybe an "expect eof"
at the end would make sure you're seeing all the output.
--
Danny Faught -- HP-Convex -- Operating System Demolitions Specialist
"Everything is deeply intertwingled."  (Ted Nelson, _Computer Lib_)


Sun, 02 Aug 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Running expect scripts from cron..?

2. problem running expect script via cron

3. cannot run expect script under cron

4. trouble running an expect script in cron versus command line

5. trouble running an Expect script from cron

6. expect: problems running script from CRON

7. Problems running expect script in the background/from cron

8. Running a cron job in SFTP using Expect

9. expect running from cron

10. expect script doesn't work with cron - please help

11. cron and expect script

12. Still problems running script from cron

 

 
Powered by phpBB® Forum Software