From owner-freebsd-questions@FreeBSD.ORG Thu May 7 06:41:48 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 78ABC106566C for ; Thu, 7 May 2009 06:41:48 +0000 (UTC) (envelope-from raghu@mri.ernet.in) Received: from hrimail.hri.res.in (hrimail.hri.res.in [210.212.50.7]) by mx1.freebsd.org (Postfix) with ESMTP id 746A58FC1C for ; Thu, 7 May 2009 06:41:47 +0000 (UTC) (envelope-from raghu@mri.ernet.in) Received: from ipc2.mri.ernet.in (unknown [192.168.3.2]) by hrimail.hri.res.in (Postfix) with ESMTP id 6C11197E8F; Thu, 7 May 2009 12:24:00 +0530 (IST) Received: from riemann.mri.ernet.in (riemann.mri.ernet.in [192.168.3.122]) by ipc2.mri.ernet.in (Postfix) with ESMTP id 7524D76255; Thu, 7 May 2009 12:11:40 +0530 (IST) Received: from riemann.mri.ernet.in (localhost [127.0.0.1]) by riemann.mri.ernet.in (8.13.6/8.13.6) with ESMTP id n476dE2j071841; Thu, 7 May 2009 12:09:14 +0530 (IST) (envelope-from raghu@riemann.mri.ernet.in) Received: (from raghu@localhost) by riemann.mri.ernet.in (8.13.6/8.13.6/Submit) id n476d5bB071840; Thu, 7 May 2009 12:09:05 +0530 (IST) (envelope-from raghu) From: "N. Raghavendra" To: Eddie Chen In-Reply-To: (Eddie Chen's message of "Wed, 6 May 2009 11:44:46 -0400") References: X-Organization: Harish-Chandra Research Institute (HRI) X-Address: Chhatnag Road, Jhusi, Allahabad 211 019, India X-URL: http://www.mri.ernet.in/ and http://www.retrotexts.net/ X-Phone: +91 (532) 2667 509, 2667 318, 2667 578, 2567 746, 2567 747 X-Fax: +91 (532) 2667 576, 2567 748, 2567 444, 2568 036 X-OpenPGP-Key-ID: 0x03618806 X-OpenPGP-Key-Fingerprint: C75D D0AF 457E 7454 BEC2 37AD C6E1 0407 0361 8806 X-OpenPGP-Public-Key-Available-At: http://www.keyserver.net/ Date: Thu, 07 May 2009 12:09:05 +0530 Message-ID: <86hbzxmn7a.fsf@riemann.mri.ernet.in> User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-questions@freebsd.org Subject: Re: ReturnCode Checking for FTP X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: "N. Raghavendra" List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 07 May 2009 06:41:48 -0000 At 2009-05-06T11:44:46-04:00, Eddie Chen wrote: > Reading the ftp commands seems to be better, because it will exit(rc) > if any of "put" or "rename" failed. Perhaps you've already looked at `lftp', http://lftp.yar.ru/ Exit codes of its commands can be used from the shell, e.g., as follows: % set SERVER="ftp://ftp.freebsd.org/pub/FreeBSD/" % lftp -c "open -e 'cat README.TXT' ${SERVER}" > /dev/null && echo "OK" OK % lftp -c "open -e 'cat NOEXIST' ${SERVER}" || echo "FAILED" FAILED Further, lftp commands themselves can use the exit codes of previous commands: % lftp -c "open -e 'ls foo && ls misc' ${SERVER}" ls: Access failed: 404 Not Found (foo) % lftp -c "open -e 'ls foo || ls misc' ${SERVER}" ls: Access failed: 404 Not Found (foo) drwxr-xr-x -- ~ drwxr-xr-x -- ~/pub drwxr-xr-x -- .. drwxr-xr-x -- . drwxr-xr-x - 2007-11-02 00:00 fbsd-compat -rw-r--r-- 1k 2002-04-03 00:00 supfile HTH, Raghavendra. -- N. Raghavendra | http://www.retrotexts.net/ Harish-Chandra Research Institute | http://www.mri.ernet.in/ See message headers for contact and OpenPGP information.