LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-08-2006, 02:16 AM   #1
wgato
Member
 
Registered: Jun 2006
Distribution: ubuntu slax dsl
Posts: 40

Rep: Reputation: 15
autoexpect & cron


when i run a script made with autoexpect from the command line, it works fine.
when i have cron run the same script it returns
spawn /bin/sh
sh-3.1$
instead of running

anyone have idea what causes this?

thanks
 
Old 10-08-2006, 09:21 AM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 75
More details?
 
Old 10-08-2006, 06:16 PM   #3
wgato
Member
 
Registered: Jun 2006
Distribution: ubuntu slax dsl
Posts: 40

Original Poster
Rep: Reputation: 15
$ /home/ktemper/ghostbin/autoftp
runs a bash script that sftp's a file to my webhost.
it works everytime when i run it from the command line as above.

the contents of the bash script are:

#!/bin/bash

cd /home/ktemper/ghostbin
./autoftp.exp


the last line is a script made with the program autoexpect.

when i add the bash script to cron with this line:
12 * * * * /home/ktemper/ghostbin/autoftp >> /home/ktemper/autoftpOutputfile

it does not sftp to my webhost and the file autoftpOutputfile contains:

spawn /bin/sh
sh-3.1$

i'm not sure what the output means and also dont understand why it works at the command line and not in cron. shouldnt they be same?

Last edited by wgato; 10-08-2006 at 06:22 PM.
 
Old 10-08-2006, 09:05 PM   #4
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 75
Two things: can you give the output of "cat /home/ktemper/ghostbin/autoftp.exp". Also, did you try changing the line "./autoftp.exp" to "exec sh autoftp.exp".
 
Old 10-08-2006, 09:27 PM   #5
wgato
Member
 
Registered: Jun 2006
Distribution: ubuntu slax dsl
Posts: 40

Original Poster
Rep: Reputation: 15
changing "./autuftp.exp" "exec sh autoftp.exp" than you for the suggestion.
i also tried opening autoftp.exp in emacs and commenting out the line
spawn $env(SHELL)
that didnt work, and it wouldnt run at the command line or in cron.


ktemper@lofi:~$ cat ghostbin/autoftp.exp
#!/usr/bin/expect -f
#
# This Expect script was generated by autoexpect on Fri Sep 22 23:05:41 2006
# Expect and autoexpect were both written by Don Libes, NIST.
#
# Note that autoexpect does not guarantee a working script. It
# necessarily has to guess about certain things. Two reasons a script
# might fail are:
#
# 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
# etc.) and devices discard or ignore keystrokes that arrive "too
# quickly" after prompts. If you find your new script hanging up at
# one spot, try adding a short sleep just before the previous send.
# Setting "force_conservative" to 1 (see below) makes Expect do this
# automatically - pausing briefly before sending each character. This
# pacifies every program I know of. The -c flag makes the script do
# this in the first place. The -C flag allows you to define a
# character to toggle this mode off and on.

set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}



set timeout -1
spawn $env(SHELL)
match_max 100000
expect -exact "]0;ktemper@lofi: ~/ghostbinktemper@lofi:~/ghostbin\$ "
send -- "sftp tantrumradio@forint.dreamhost.com\r"
expect -exact "Password: "
send -- "UWneYP#\r"
expect -exact "sftp> "
send -- "cd tantrumradio.com/playlist"
expect -exact "cd tantrumradio.com/playlist"
send -- "\r"
expect -exact "sftp> "
send -- "put playlisy"
expect -exact [K"
send -- "
expect -exact [K"
send -- "t.html\r"
expect -exact "sftp> "
send -- "quit\r"
expect -exact "]0;ktemper@lofi: ~/ghostbinktemper@lofi:~/ghostbin\$ "
send -- "exit\r"
expect eof
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can any one plz explain why/what for cron.d, cron.daily, cron.weekly etc are there. mavinashbabu Linux - Newbie 4 09-21-2006 01:50 PM
cron & MAILTO mikeshn Linux - Software 1 04-17-2006 04:06 AM
cron & backup howto ? crispyleif Linux - Software 4 11-23-2005 12:26 PM
logrotate && cron pH* Linux - General 9 12-21-2004 10:38 AM
using autoexpect paintLinux Programming 3 01-19-2004 05:42 PM


All times are GMT -5. The time now is 02:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration