FTP EOF n00b Question


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers FTP EOF n00b Question
# 1  
Old 02-20-2012
FTP EOF n00b Question

Hi folks, can you help me decipher this?

I know that ftp will accept input from all commands until it encounters EOF again but I don't quite make sense of what the entirety of the script is really trying to achieve.

Many thanks.

Code:
ftp -n someserver << EOF | head -20
user username@server password
ascii
ls -lt
EOF 
exit

# 2  
Old 02-20-2012
It is called a here document - like typing the stuff live into ftp, but the script does the "typing".

The "<<EOF" and "EOF", mark the boundaries of the here doc. << EOF is the start, EOF (in absolutely the first column) marks the end.

"EOF" can be almost anything that is not a variable or a command, old stinkers like me use an exclamation point: !

EOF is sort of a de facto standard for that. You could use FARKLE or AuntMartha
if you wanted to.
# 3  
Old 02-20-2012
In summary the script tries to display a directory list of the most recent 20 files from the remote server.

The script is showing the first 20 lines (head -20) of the output of a simple ftp session which displays a directory listing from the remote system.
The ftp session logs in with username and password changes the file transfer mode to "ascii" (not "binary") and asks the remote system for a directory list. Whether this directory list will actually come out in descending date order (ls -tr) is a matter of implementation of ftp on the servers involved.
The "ascii" command is pointless in this context but a good reminder to positively set ascii/binary when actually moving files.

The script could be improved by placing a ftp "quit" command as the last ftp command before the "EOF".
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell pipeline help for a n00b

I need to read input from a file, and make sure nothing prints after column 72. basically, ignore input after character 72 until the next newline character. Any help is appreciated. I have been searching forever! (10 Replies)
Discussion started by: Gbear
10 Replies

2. Shell Programming and Scripting

Unix Shell basic loop massive n00b

hey guys I would really appreciate some help, i need to do a project for a job that requires minimal UNIX scripting and im REALLY stuck basically Im stuck at what i believe is something really simple but i just dont have a clue how to do it efficiently and properly and i REALLY appreciate some... (16 Replies)
Discussion started by: thurft
16 Replies

3. Shell Programming and Scripting

Shell Scripting n00b

Hey Guys! I was hoping for some help with a simple script I'm trying to use. I have the script set up to pull some simple information out of a database .txt file and sed it into a preexisting template for assignment cover letters. The problem seems to be someplace in the sed statement but I... (5 Replies)
Discussion started by: BFeicht
5 Replies

4. Shell Programming and Scripting

confused with << EOF EOF

Hi friends , I am confused with << EOF EOF Most of the cases I found sqlplus $db_conn_str << EOF some sql staments EOF another exapmle is #!/bin/sh echo -n 'what is the value? ' read value sed 's/XXX/'$value'/' <<EOF The value is XXX EOF (1 Reply)
Discussion started by: imipsita.rath
1 Replies

5. IP Networking

tcp n00b - can't ping router

please help! I have a sun blade with 2 x nics configured, both on different subnets. The eri0 interface (192.168.0.100) is connected to my router (192.168.0.1), but if i try to ping the router, it times out. any suggestions are welcome - i noticed the 2 mac addresses are the same, i've set... (7 Replies)
Discussion started by: badoshi
7 Replies

6. Shell Programming and Scripting

scripting n00b question, please help :)

Okay, so I'm a little familiar with C and Linux, but my shell scripting experience is limited to say the least. I know that you begin a shell script with this #!/bin/bash Basically, I've written a C program that's output writes to a shell script. What my problem is, is I would like this shell... (4 Replies)
Discussion started by: beatzz
4 Replies

7. UNIX for Dummies Questions & Answers

N00b In Need!

Howdy all, just joined the forums after finding them on a good ole' google search. very impressed from what i've seen so far! I'm pretty new to the world of Unix/Linux, have just had a change of job role and been thrown in at the deep end! I'm now working on an Oracle 9i database using HPUX... (1 Reply)
Discussion started by: davesimm
1 Replies

8. UNIX for Dummies Questions & Answers

N00b question on CPU % in top

I have a process in my TOP output that is consistantly at 97% usage. I have 16 CPUs on my box. So is the 97% the cumalative usage of all the CPUs or just one? (3 Replies)
Discussion started by: kskywr
3 Replies

9. UNIX for Dummies Questions & Answers

Absolute n00b questions about Unix / Linux

Hi All, I have absolutely no experince with either one, and would LOVE to start from somewhere! So please guide me to some web sites (beside these great forums of course!) that I can obtain n00b information. (Books, links, resources, etc.) What software OS? should I begin with? I have heard... (2 Replies)
Discussion started by: CodeHunter
2 Replies

10. UNIX for Dummies Questions & Answers

OpenBSD N00b: HELP ME!!! AGGGH!!

Note: This is not meant to start a flamewar. I am looking for serious answers to questions regarding OpenBSD. I'm coming to OpenBSD from an eight year background in Linux (specifically various versions of RedHat and now Fedora Core 3). I have some experience with Solaris 8 and HP-UX 11/11i. I... (1 Reply)
Discussion started by: deckard
1 Replies
Login or Register to Ask a Question