Здравствуйте.
Есть скрипт написанный на expect для копирования с цисок ранов на тфтп сервер. Когда запускаю вручную из баша и из под рута, то скрипт работает. Ставлю его в cron.
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
set dates [lindex $argv 0]
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn ssh логин@ипка
match_max 100000
expect -exact "\r\r
-----------------------------------------------------------------------\r
Cisco Router and Security Device Manager (SDM) is installed on this device. \r
This feature requires the one-time use of the username \"cisco\" \r
with the password \"cisco\". The default username and password have a privilege level of 15.\r
\r
Please change these publicly known initial credentials using SDM or the IOS CLI. \r
Here are the Cisco IOS commands.\r
\r
username <myuser> privilege 15 secret 0 <mypassword>\r
no username cisco\r
\r
Replace <myuser> and <mypassword> with the username and password you want to use. \r
\r
For more information about SDM please follow the instructions in the QUICK START \r
GUIDE for your router or go to http://www.cisco.com/go/sdm \r
-----------------------------------------------------------------------\r
Password: "
send -- "пароль\r"
expect -exact "\r
\r
nizh#"
send -- "copy run tftp://ипка/$dates"
expect -exact "copy run tftp://ипка/$dates"
send -- "\r"
expect -exact "\r
Address or name of remote host \[ип\]? "
send -- "\r"
expect -exact "\r
Destination filename \[$dates\]? "
send -- "\r"
expect -exact "\r
!!\r
18273 bytes copied in 0.628 secs (29097 bytes/sec)\r
nizh#"
send -- "exit\r"
expect eof
потому-что в целях безопасности crond использует стандартную date. А в POSIX нет %H - это гнутое расширение. Забыл я вам об этом сказать сразу...
ЗЫЖ поправочка:
text
`date' conversion specifiers related to times.
`%H'
hour (`00'...`23')
`%I'
hour (`01'...`12')
`%k'
hour (` 0'...`23'). This is a GNU extension.
`%l'
hour (` 1'...`12'). This is a GNU extension.
`%M'
minute (`00'...`59')
`%N'
nanoseconds (`000000000'...`999999999'). This is a GNU extension.
`%p'
locale's equivalent of either `AM' or `PM'; blank in many locales.
Noon is treated as `PM' and midnight as `AM'.
`%P'
like `%p', except lower case. This is a GNU extension.
`%r'
locale's 12-hour clock time (e.g., `11:11:04 PM')
`%R'
24-hour hour and minute. Same as `%H:%M'. This is a GNU
extension.
`%s'
seconds since the epoch, i.e., since 1970-01-01 00:00:00 UTC.
Leap seconds are not counted unless leap second support is
available. *Note %s-examples::, for examples. This is a GNU
extension.