Cron job using Expect to Telnet

Cron job using Expect to Telnet

Post by Al Mc Elro » Mon, 14 Aug 2000 04:00:00



OS: Solaris 2.7
I use an Expect script to telnet to a machine and login as a user with ftp
firewall privileges.
From the telnet'ed user Id and machine,  run another Expect ftp script to
get files from ftp server.

Both Expect scripts work fine running from bash cmdtool.

Using cron to run the 2 Expect scripts daily(first telnet, then ftp) is
* and cron is not emailing any error
messages.

Searched the Web but have not found solution to cron and telnet problem.

Any ideas / solutions ?

Thanks
Al

 
 
 

Cron job using Expect to Telnet

Post by Derek M. Fly » Tue, 15 Aug 2000 04:00:00


[snip]

Quote:> Using cron to run the 2 Expect scripts daily(first telnet, then ftp) is
>* and cron is not emailing any error
> messages.

> Searched the Web but have not found solution to cron and telnet problem.

> Any ideas / solutions ?

Insert some echo statements in your shell scripts, puts statements in your
expect scripts and try to figure out where they are*.

 
 
 

1. HELP!! Cron problem using Expect on AIX 4...

Hello, I am running into trouble with Cron using Expect and need some
assistance if someone(s) would oblige.

I am using:
IBM RISC 6000 running AIX 4.2.1
Expect 5.28
TCL 8.0
root access

I am trying to automate a third party backup module that only asks 3
questions from the user (which drive to send the data?, weekly/daily?,
and concurrent with MUMPS?). Easy enough to automate with the power of
Expect... you would think, but Cron doesn't want to help. I can run the
script at the prompt ( >expect backup.exp) and it does fine (I created
it with the beautiful autoexpect and tweaked it until it worked). But
when I put it in cron it kicks off and sits there. I can see in "ps -ef"
that expect has started at the desinated time, but thats all it does.  I
have to go and kill the cron job (left one sitting for 24 hours before
killing). I bought "Exploring Expect" but after a week I don't see my
problem (not much help on Cron in the book). I created a smaller version
of my script to just test the water (kinda like inserting printf
statements in C) and here it is:

set timeout -1
set send_slow {1 .1}
set env(TERM) vt100
spawn $env(SHELL)
match_max 100000
send -s -- "cd /sunquest/backup\r"
expect -exact "sunquest/backup:>"
send -s -- "pwd > pwdtest\r"
expect -exact "sunquest/backup:>"
send -s -- " "
expect eof

Run from the prompt it does what it is supposed to:
---------------

spawn /bin/ksh




---------------

/sunquest/backup/pwdtest

---------------

But fails in cron for some reason (it doesn't make the pwdtest file).
It is called in crontab as:
30 11 * * * /src/expect-5.28/expect /src/expect-5.28/test27.exp

If you could offer any help, please cc me in email or send it to me
directly.
If you need more info, email me also.
Thanks in advance,
Greg Gilleland

2. New video card, now linux won't start

3. using expect for telnet connection

4. tape backup from Irix to SCO

5. Using expect to retrieve an html file via telnet - ?

6. Lexmark1100 & RedHat5.1

7. PPP over telnet using expect script

8. PLEASE: Opti930 card

9. seeking methods/techniques for robust error check/handling using expect, ksh, perl to ftp/telnet

10. update hardware clock using hwclock as a cron job

11. backup in tape drive using cron jobs for newbie

12. using a perl script in cron job