From owner-freebsd-questions Fri Nov 15 9:33:49 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 90EA037B401 for ; Fri, 15 Nov 2002 09:33:46 -0800 (PST) Received: from dexter.starfire.mn.org (starfire.skypoint.net [199.199.159.71]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9DE4A43E3B for ; Fri, 15 Nov 2002 09:33:44 -0800 (PST) (envelope-from john@dexter.starfire.mn.org) Received: (from john@localhost) by dexter.starfire.mn.org (8.11.3/8.11.3) id gAFHXgD83011 for freebsd-questions@FreeBSD.ORG; Fri, 15 Nov 2002 11:33:42 -0600 (CST) (envelope-from john) Date: Fri, 15 Nov 2002 11:33:42 -0600 From: John To: freebsd-questions@FreeBSD.ORG Subject: Re: FTP and cron Message-ID: <20021115113342.A82992@starfire.mn.org> References: <20021115103931.A82781@starfire.mn.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <20021115103931.A82781@starfire.mn.org>; from john@starfire.mn.org on Fri, Nov 15, 2002 at 10:41:24AM -0600 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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