Hi,
I have a script that i want to run daily
i placed the script in /etc/cron.daily/ (as root)
the script launches an expect script which connects to a remote server via sftp2
the secure shell requires a user interactive password to be entered, so expect script is the only way i could think of to accomplish this task automatically
if i run the script by itself, it runs perfectly
the problem is it won't run from cron.daily or crontab entry
i've tried everything, help!
/etc/cron.daily/lograbber
#!/bin/sh
/home/ `date --date=yesterday +%Y
%m%d`
heres what the lograbber.exp script looks like:
#!/usr/bin/expect -f
set force_conservative 0
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} { sleep .1
exp_send -s -- $arg }
}
set filedate [lindex $argv 0];
set timeout -1
spawn /home/ user@123.123.123.123
match_max 100000
expect -exact "user@123.123.123.123's password:"
send -- "xxxxxxx\r"
expect -exact "sftp>"
send -- "cd /logs/archive\r"
expect -exact "sftp>"
send -- "lcd /logs/archive\r"
expect -exact "sftp>"
send -- "get mywebsite.$filedate.zip\r"
expect -exact "sftp>"
send -- "quit\r"
spawn /usr/bin/zip -d /logs/archive/mywebsite.$filedate.zip \*error\*
expect eof
I have a script that i want to run daily
i placed the script in /etc/cron.daily/ (as root)
the script launches an expect script which connects to a remote server via sftp2
the secure shell requires a user interactive password to be entered, so expect script is the only way i could think of to accomplish this task automatically
if i run the script by itself, it runs perfectly
the problem is it won't run from cron.daily or crontab entry
i've tried everything, help!
/etc/cron.daily/lograbber
#!/bin/sh
/home/ `date --date=yesterday +%Y
%m%d`
heres what the lograbber.exp script looks like:
#!/usr/bin/expect -f
set force_conservative 0
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} { sleep .1
exp_send -s -- $arg }
}
set filedate [lindex $argv 0];
set timeout -1
spawn /home/ user@123.123.123.123
match_max 100000
expect -exact "user@123.123.123.123's password:"
send -- "xxxxxxx\r"
expect -exact "sftp>"
send -- "cd /logs/archive\r"
expect -exact "sftp>"
send -- "lcd /logs/archive\r"
expect -exact "sftp>"
send -- "get mywebsite.$filedate.zip\r"
expect -exact "sftp>"
send -- "quit\r"
spawn /usr/bin/zip -d /logs/archive/mywebsite.$filedate.zip \*error\*
expect eof