Operating System - Linux
1824976 Members
3541 Online
109678 Solutions
New Discussion юеВ

What does "<<" do in - ftp -n something.com <<EndFTP

 
SOLVED
Go to solution
John Jimenez
Super Advisor

What does "<<" do in - ftp -n something.com <<EndFTP

We have a several scripts that ftp into another server like this below:

ftp -n something.com <
what does << do?

a few lines later farther down is EndFTP again. If we remove the <
Hustle Makes things happen
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: What does "<<" do in - ftp -n something.com <<EndFTP

This is known as a 'here docs' input. <This is some
input stuff
EndFTP

would read:
This is some
input stuff

just as though you have typed it yourself. <
If it ain't broke, I can fix that.
Sandman!
Honored Contributor

Re: What does "<<" do in - ftp -n something.com <<EndFTP

Search the sh-posix(1) manpage for "here-document"...see excerpt below:

<<[-]word The shell input is read up to a line that matches
word, or to an end-of-file. No parameter
substitution, command substitution or file name
generation is performed on word. The resulting
document, called a here-document, becomes the
standard input. If any character of word is
quoted, no interpretation is placed upon the
characters of the document. Otherwise, parameter
and command substitution occurs, \newline is
ignored, and \ must be used to quote the
characters \, $, `, and the first character of
word. If - is appended to <<, all leading tabs
are stripped from word and from the document.
John Jimenez
Super Advisor

Re: What does "<<" do in - ftp -n something.com <<EndFTP

Wow, that has to be a record on solving a question. Thanks a bunch for the information
Hustle Makes things happen