You might find this useful, I hope:
#!/bin/sh : # @(#) transfer Transfer files via ftp to/from remote host. # Author: James W. Brown, July 1992. PATH=$PATH:/usr/sbin; export PATH # Add directory containing ping exit_status=0 # No error condition exit code lflag="" # Don't use log by default tdirection=mget # Retrieve file by default tmode=ascii # Use ASCII representation type by default LogFile=$HOME/.transfer_log # Log file path usage_exit(){ cat << EOF >&2 Usage: `basename $0` [-p] [-b] [-l] [-s] [-r rem-dir] -h host file... -p Put instead of take the file -b Use binary instead of ASCII mode -l Store messages from ftp in log file -s Silent mode ( no loging ) -r rem-dir Specify remote directory instead of default (.) -h host Remote host name file... File(s) to be transferred EOF exit_status=1 ; exit } # Set trap to restore .netrc file: trap '[ -f $HOME/.netrc% ] && mv $HOME/.netrc% $HOME/.netrc; exit $exit_status' 0 1 2 3 15 # Process command-line options: if [ "$OPTIND" = 1 ]; then # can use getopts while getopts bh:lpr:s options; do echo $options case "$options" in b) tmode=binary ;; h) host=$OPTARG ;; l) lflag=yes ;; p) tdirection=mput ;; r) remdir=$OPTARG ;; s) LogFile=/dev/null; lflag=yes;; \?) usage_exit ;; esac done shift `expr $OPTIND - 1` # shift options of the way else # getopts not available while [ $# -gt 0 ]; do case $1 in -b) tmode=binary ; shift ;; -h) if [ ! "$2" ]; then echo "-h option requires an argument" >&2 usage_exit else host=$2 ; shift ; shift fi ;; -l) lflag=yes ; shift ;; -s) LogFile=/dev/null; lflag=yes ; shift ;; -p) tdirection=mput ; shift ;; -r) if [ ! "$2" ]; then echo "-r option requires an argument" >&2 usage_exit else remdir=$2 ; shift ; shift fi ;; --) shift; break ;; # end of option list -*) echo "Unrecognized option \"$1\"" >&2 usage_exit ;; *) break ;; # saw first non-option argument esac done fi # Check for non-option (file) argument(s): case $# in 0) echo "Must specify at least one file argument" >&2 usage_exit ;; esac # Check for remote system name, remote directory: if [ ! "$host" ]; then echo "You must specify a remote host machine." >&2 usage_exit elif [ ! "$remdir" ]; then # If no remote directory, then remdir="." # use current directory fi # Echo a packet to see if remote host is reachable: if ping $host 64 1 >/dev/null 2>&1; then # if ping $host >/dev/null 2>&1; then : # No problem else echo "$host either down or doesn't exist." >&2 ; exit_status=2; exit fi # Check .netrc file: if [ -f $HOME/.netrc ]; then hostinfo=`grep $host ${HOME}/.netrc` if [ ! "$hostinfo" ]; then echo "No $host entry found in $HOME/.netrc, exiting..." >&2 exit_status=4 ; exit fi mv $HOME/.netrc $HOME/.netrc% # Save original file # Create new .netrc that's only accessible by owner: touch $HOME/.netrc chmod go-rw $HOME/.netrc else echo "$HOME/.netrc not found, exiting ..." >&2; exit_status=3 ; exit fi # Put the set-up information into .netrc: cat << EOF >> $HOME/.netrc $hostinfo macdef init cd $remdir $tmode prompt $tdirection $* quit EOF # Log transaction in file or on standard output: if [ "$lflag" ]; then date >> $LogFile # note date/time ftp $host >> $LogFile # log ftp messages else ftp $host fi

ciao,
Roberto

"A child of five could understand this. Fetch me a child of five." (G.Marx)

In reply to Re: using system or Shell by rbi
in thread using system or Shell by lanier

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.