topical media & game development

talk show tell print

basic-shell-05-ftpget.sh / sh



  
  # Driving an interactive program, ftp.
  
  # Validate number of arguments.
  if [ # -lt 2 ]
  then
      echo "Error, usage is:"
      echo "ftpget hostname filename [directory]."    
      exit -1
  fi
  
  hostname=$1
  filename=$2
  
  directory="."  # Default value
  
  if [ # -ge 3 ]
  then
      directory=$3
  fi
  
  ftp <<EndOfSession
  open hostname
  
  cd directory
  get filename
  quit
  
  EndOfSession
  
  echo "FTP session ended."
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.