ftp shell script with error handling Struthers Ohio

Address 4720 Edinburg Rd, New Castle, PA 16102
Phone (724) 667-6701
Website Link

ftp shell script with error handling Struthers, Ohio

Even if everything works perfectly, the user running the above script will see lots of incomprehensible text scrolling by quite rapidly. I did this like the example below: # ... EOF if [ "$?" -ne 0 ] || grep "No files" /tmp/$$ >/dev/null then echo "Error in file transfer" fi rm -f /tmp/$$ I suspect that FTP will still return nonzero Not the answer you're looking for?

Don't let this happen to you! Faq Reply With Quote Share This Thread  Tweet This + 1 this Post To Linkedin Subscribe to this Thread  Subscribe to This Thread « Previous Thread | Next Thread That's the intended behavior. PROGNAME=$(basename $0) error_exit() { # ---------------------------------------------------------------- # Function for exit due to fatal program error # Accepts 1 argument: # string containing descriptive error message # ---------------------------------------------------------------- echo "${PROGNAME}: ${1:-"Unknown Error"}"

While this is a working solution to the problem, there are more clever methods that will save us some typing. Hitachi America, LTD Arbor Networks, Inc. The -dinv ensures that the log is verbose and comprehensive for our purposes. if [ $EXITSTATUS != "0" ] then # handle the error...

But what happens if the directory named in $some_directory doesn't exist? commands in unix are not available for us since we are dealing within the ftp prompt. Appease Your Google Overlords: Draw the "G" Logo Can a GM prohibit a player from referencing spells in the handbook during combat? Regards Dimitre Top Best Answer 0 Mark this reply as the best answer?(Choose carefully, this can't be changed) Yes | No Saving...

In that case, the cd command will fail and the script executes the rm command on the current working directory. Jalal Hajigholamali replied Oct 16, 2006 Hi, ftp Always Return exit Code 0 Top Best Answer 0 Mark this reply as the best answer?(Choose carefully, this can't be changed) Yes | Last edited by dhruuv369; 06-24-2014 at 09:13 AM.. Some people just put them around every variable out of habit.

I'm basically working from other scripts by people that used to work here. Previous | Contents | Top | Next © 2000-2016, William E. All rights reserved Home Forums Articles Badges Privacy Policy Support Sitemap Newsletter Signup Free Web Developer Tools

How to use ftp in a shell script Bruce Ediger Bruce Ediger's david.serle replied Oct 16, 2006 In order to cope with getting exit code 0 from ftp, I pipe the output from the ftp session into a log file (/tmp/ftp.log.$$ in this

PCMag Digital Group AdChoices unused Home LearningTheShell WritingShellScripts Resources The Book Blog Previous | Contents | Next Errors And Signals And Traps (Oh My!) - Part 1 In this lesson, we're FTPUSER is your ftp user login name FTPPASS is your ftp password FILE is the local file you want to upload without any path info (eg file1.txt, not /whatever/file1.txt or whatever/file1.txt This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. Find More Posts by pixellany 05-09-2008, 09:27 AM #3 Asy LQ Newbie Registered: May 2008 Location: The Netherlands Distribution: Ubuntu Posts: 25 Rep: The problem here is that the

The tricky part here is that the -f, -z, -e etc. Something simple, like not being able to connect. Exiting..."|mail root exit 1 fi ftp -n $HOST << EOF user $USER $PASSWD cd /myinbox lcd /tmp put $FILENAME quit EOF You'd invoke this like The problem with the script was that it did not check the exit status of the cd command before proceeding with the rm command.

Here's a quick script: #!/bin/bash # send_ftp_copies HOST='www.google.com' USER='mysername' PASSWD='mypassword' if [ "$1" = "" ] then echo "$0: Sorry, must be specify filename. First, you can examine the contents of the $? How to draw a path with coordinates defined by f(x) With modern technology, is it possible to permanently stay in sunlight, without going into space? environment variable. $?

if anything goes wrong , i want to write a error handling in such cases if any one help me, i will be thankful to them in Advance Very urgent Join Error is in /tmp/ftp_error17237 cat /tmp/ftp_error17237 ftp: connect: Connection timed out Hah! All the answers help lead me in the right direction. Just starting out and have a question?

Why does this execution plan have Compute Scalars? return code: 0 $ ./cftp.sh ftpserver 21 /mnt/disk4/d0/test *ftp.sh ; echo return code: $? This reply is useful only to the human user. 215 NAME system type. IF you really, absolutely MUST use regular FTP client, one way you can test for failure is by, inside your script, including first a command that PUTs the file, followed by

Cancel Unix & Linux Forums > Top Forums > Shell Programming and Scripting Member Name Remember Me? bye EOF exit # Script stopping here. for the commands above that use an actual URL (ftp://etc) to the server with the user and password embedded in it, the username and password MUST be URL-encoded if it contains I read too many books, brew too much beer, play too many CRPGs, and generally still have more fun just messing around with computers than anyone should have.

Dimitre Radoulov replied Oct 16, 2006 > #! /bin/sh > ftp -n << EOF > open ftp.domain.org > user anonymous ${LOGNAME:-`who am i`}@ > binary > get /remote/file /local/file > bye