Running expect scripts from cron..? 
Author Message
 Running expect scripts from cron..?

Hail peeps

I have written a quick script to do multiple scp's without password prompt
but although fine from a shell it wont work when cronned?

Can anyone help me - the script is small and I would really appreciate any
input, perhaps someone else has had a similar problem.

Thanks.

Kev.

--------Script----------

#!/usr/bin/expect
#####################################
set date [clock format [clock seconds] -format %D]
set copy_date [clock format [clock seconds] -format %Y%m%d]
set year [clock format [clock seconds] -format %Y]
set month [clock format [clock seconds ] -format %m]
set day [clock format [clock seconds] -format %d]
set backup_machine [lindex $argv 0]
set target_machine [lindex $argv 1]
set base_dir "/disk1/logfiles/internet/$target_machine"
set old_file [exec find "$base_dir" -mtime -1 -type f]
if { $old_file != "" } { set old_file_size [file size $old_file]}
regsub -all / $date - date
#####################################

spawn scp

/tmp/$copy_date$target_machine.masq.log
expect "assword:"
send "<in the real script my pass is here>\r"
interact

set new_file_size [file size /tmp/$copy_date$target_machine.masq.log]exec
mkdir -p $base_dir/$year/$month >> /dev/null
if { $old_file == "" } {set old_file_size 0 }

if  { $old_file_size != $new_file_size } { exec mv -f
/tmp/$copy_date$target_machine.masq.log
$base_dir/$year/$month/$target_machine.$copy_date\masq.gz >> /dev/null }

-----Error when cronned -----


/tmp/20010731gw1.masq.log

such file or directory
    while executing
"file size /tmp/$copy_date$target_machine.masq.log"
    (file "/home/log-pull/scripts/masq_copy.tcl" line 22)
Null message body; hope that's ok



Sun, 18 Jan 2004 00:21:20 GMT  
 Running expect scripts from cron..?

Quote:

> Hail peeps

> I have written a quick script to do multiple scp's without password prompt
> but although fine from a shell it wont work when cronned?

Try reading...
http://mini.net/tcl/cron

Bob
--

Mayo Foundation                                 (507) 538-5495
200 First St. SW                            FAX (507) 284-9171
Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/



Sun, 18 Jan 2004 01:36:24 GMT  
 Running expect scripts from cron..?
Hmm - Thanks Bob.

I think this has put me on the right line though I've still not found a

crontab and also loading some env variables but no joy.  Will continue
hunting anyhow :)

--
Kev.


Quote:

> > Hail peeps

> > I have written a quick script to do multiple scp's without password
prompt
> > but although fine from a shell it wont work when cronned?

> Try reading...
> http://mini.net/tcl/cron

> Bob
> --

> Mayo Foundation                                 (507) 538-5495
> 200 First St. SW                            FAX (507) 284-9171
> Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/



Sun, 18 Jan 2004 18:53:01 GMT  
 Running expect scripts from cron..?
For any other tcl newbies it was the `interact` statement that confused the
cron (which makes sense).

I personally got round this by specifying a really long timeout and then
using `expect timeout` though im told `expect eof` may work for some apps.

--
Kev

Quote:
> Hmm - Thanks Bob.

> I think this has put me on the right line though I've still not found a

within
> crontab and also loading some env variables but no joy.  Will continue
> hunting anyhow :)

> --
> Kev.




> > > Hail peeps

> > > I have written a quick script to do multiple scp's without password
> prompt
> > > but although fine from a shell it wont work when cronned?

> > Try reading...
> > http://mini.net/tcl/cron

> > Bob
> > --

> > Mayo Foundation                                 (507) 538-5495
> > 200 First St. SW                            FAX (507) 284-9171
> > Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/



Mon, 19 Jan 2004 18:15:56 GMT  
 Running expect scripts from cron..?
The default for eof and timeout are empty actions so ...

  expect
  expect eof
  expect timeout

....all do the same thing.

Don

Quote:

> For any other tcl newbies it was the `interact` statement that confused the
> cron (which makes sense).

> I personally got round this by specifying a really long timeout and then
> using `expect timeout` though im told `expect eof` may work for some apps.

> --
> Kev


> > Hmm - Thanks Bob.

> > I think this has put me on the right line though I've still not found a

> within
> > crontab and also loading some env variables but no joy.  Will continue
> > hunting anyhow :)

> > --
> > Kev.




> > > > Hail peeps

> > > > I have written a quick script to do multiple scp's without password
> > prompt
> > > > but although fine from a shell it wont work when cronned?

> > > Try reading...
> > > http://mini.net/tcl/cron

> > > Bob
> > > --

> > > Mayo Foundation                                 (507) 538-5495
> > > 200 First St. SW                            FAX (507) 284-9171
> > > Rochester MN, 55901  USA            http://www.mayo.edu/sppdg/



Tue, 20 Jan 2004 01:45:20 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Running EXPECT script through 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