LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-09-2008, 08:49 AM   #1
RedOctober45
Member
 
Registered: Aug 2007
Distribution: OFFICE: Solaris, RedHawk
Posts: 65

Rep: Reputation: 15
automated FTP shell script


Hello!

I am trying to get the following automated FTP script to work. However, I don't understand what the "EOF" or "END_SCRIPT" command is referring to or what it is or does. Can someone clear this up for me?

Thanks!!!

Code:
#!/bin/bash

ftp_site=ftp://yoursite.com
username=roger
passwd=abc123
backupdir=$HOME
filename="backup-$(date '+%F-%H%M').tar.gz"

echo "Creating a backup file $filename of $backupdir."

# Make a tar gzipped backup file
tar -cvzf "$filename" "$backupdir"

ftp -in <<EOF
open $ftp_site
user $username $passwd
bin
put $filename 
close 
bye
EOF
 
Old 01-09-2008, 08:58 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,453

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
It is a so-called "here document". The syntax
Code:
command << string
line1
line2
string

it passes some input to command (ftp in your example) spread over multiple lines until string (EOF in your example) is encountered. Note that you should not put any blank space or tab character before the string at the end. For a more detailed explanation you can refer to the Advanced Bash Scripting Guide, chapter 18.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Auto ftp shell script mcrosby Linux - Newbie 9 06-27-2007 06:09 AM
ftp through shell script HSN Programming 24 02-23-2007 03:18 PM
shell script to transfer file from ftp bbgtilak Linux - General 1 12-27-2006 07:35 AM
Automated FTP script to grab ONLY newest dated files kaiserbeto Linux - Newbie 4 10-20-2006 02:46 AM
shell script for ftp javier_ccs Programming 7 07-18-2006 11:02 PM


All times are GMT -5. The time now is 03:45 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration