HP3000-L Archives

March 2012, Week 2

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Edward Berner <[log in to unmask]>
Reply To:
Edward Berner <[log in to unmask]>
Date:
Thu, 8 Mar 2012 20:22:43 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (45 lines)
Hello,

Some thoughts and ramblings about your FTP functions...

You might have trouble with filenames containing spaces.  Not only the file being transfered but also things like your "elog" file.  Additional quoting would help in some cases 'cat "${7}"' instead of 'cat ${7}', for example, but I'm not sure what to do inside the "here documents" with the ftp commands.

Stylistically, I usually omit the braces around the numbered variables ($1 instead of ${1}, for example) but use them for alphanumeric variable names.  Either way works, just a matter of taste.

Stylistically, I'm not sure I'd have the functions exit the script on error.  But I can see where it'd be convenient, so maybe I'd provide a global variable to control that behavior, ftp_exit_on_error or something.

Grep should return a non-zero exit code if it matches anything, so your ftp status checks could probably be rewritten like this:

if grep 550 ${7}; then
    return 1
fi

But grep will also output the matching lines by default which you don't want in this case.  Some greps have a -q option or something to tell them to be quiet.  Otherwise you can use:

if grep 550 ${7} > /dev/null 2>&1 ; then
    return 1
fi

You could make that even shorter using the &&amp; operator instead of the if statement:

grep 550 ${7} > /dev/null 2>&1 &&amp; return 1

That'll make the script a bit shorter but also a bit harder to read.

Finally, as an entirely different way to do it, kermit can also be used to automate FTP transactions.  See the following for more information:

    The Kermit FTP Client - Secure Scriptable FTP
    http://www.kermitproject.org/ftpclient.html

    FTP Script Writing - How Do I Automate an FTP Session?
    http://www.kermitproject.org/ftpscripts.html


-- 
Edward Berner
Information Technology Operations
Yosemite Community College District

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2