Skip to Content
Learning Linux Shell Scripting - Second Edition
book

Learning Linux Shell Scripting - Second Edition

by Ganesh Sanjiv Naik
May 2018
Beginner
332 pages
7h 28m
English
Packt Publishing
Content preview from Learning Linux Shell Scripting - Second Edition

Using the << here operator for FTP usage and data transfer

FTP is a commonly used <indexentry content="here document:<protocol to transfer data on websites. FTP stands for File Transfer Protocol. The following steps show the <indexentry content="here document:<usage of FTP and data transfer:

  1. Write the here_07.sh script:
#!/bin/bash 
# Checking number of arguments passed along with command 
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 << End_Of_Session 
open $hostname 
cd $directory 
get $filename 
quit 
End_Of_Session 
echo "FTP session ended." 
  1. Save the file, give the permission to execute, and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting

Learning Linux Shell Scripting

Ganesh Sanjiv Naik
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781788993197Supplemental Content