Date: Fri, 15 Nov 2002 11:33:42 -0600 From: John <john@starfire.mn.org> To: freebsd-questions@FreeBSD.ORG Subject: Re: FTP and cron Message-ID: <20021115113342.A82992@starfire.mn.org> In-Reply-To: <20021115103931.A82781@starfire.mn.org>; from john@starfire.mn.org on Fri, Nov 15, 2002 at 10:41:24AM -0600 References: <20021115103931.A82781@starfire.mn.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Nov 15, 2002 at 10:41:24AM -0600, John wrote: > I'm having fits running ftp from cron jobs. Shell or "expect" > scripts that execute perfectly from the terminal fail in a seeminly non- > deterministic variety of ways when run from cron. Just for completeness, here are the cron results and redirected file outputs, respectively, of the results of running the same stripped-down script. This script doesn't do all the prework that the "big" script does, but it still demonstrates the problem. Following both outputs is the script itself. The "set env(TERM) vt100" thing was just a desparation measure I tried after reading in the expect man page about telnet hanging if there is no TERM environment set. Since "new" ftp can do somewhat sophisticated terminal things (progress bars), I thought it was worth trying. No difference. The only "cleverness" in this is to try to detect if things are working correctly or not by use of the hash detection and the "exp_continue". If you chop that out and adjust the timeout value accordingly, it will take the script longer to fail (with a slow connection, which is what I'm dealing with), but again, the aggregate results are the same. I wish to emphasize that it's not purely an "expect" thing. I get the same aggregate results (a 0-length file created at the remote site and nothing else) from shell scripts, just less feedback. spawn ftp space.augsburg.edu Connected to aug20.augsburg.edu. 220 space.augsburg.edu FTP server ready. 331 Password required for mtm. 230 User mtm logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> progress off Progress bar off. ftp> hash 8192 Hash mark printing on (8192 bytes/hash mark). ftp> put crewtestdump local: crewtestdump remote: crewtestdump 200 PORT command successful. ftp put timeout spawn ftp space.augsburg.edu Connected to aug20.augsburg.edu. 220 space.augsburg.edu FTP server ready. 331 Password required for mtm. 230 User mtm logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp> progress off progress off Progress bar off. ftp> hash 8192 Hash mark printing on (8192 bytes/hash mark). ftp> put crewtestdump local: crewtestdump remote: crewtestdump 150 Opening BINARY mode data connection for crewtestdump. ##### 226 Transfer complete. 47150 bytes sent in 16.41 seconds (2.80 KB/s) ftp> quit quit 221-You have transferred 47150 bytes in 1 files. 221-Total traffic for this session was 47535 bytes in 1 transfers. 221-Thank you for using the FTP service on space.augsburg.edu. 221 Goodbye. #!/usr/local/bin/expect set env(TERM) vt100 set timeout 120 spawn ftp space.augsburg.edu expect "ftp> " send "progress off\r" expect "ftp> " send "hash 8192\r" expect "ftp> " send "put crewtestdump\r" expect "ftp> " {puts "unexpected prompt"; exit} \# {exp_continue} timeout {puts "ftp put timeout"; exit} 226 expect "ftp> " send quit\r expect -- John Lind john@starfire.MN.ORG To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021115113342.A82992>