LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-18-2008, 04:39 AM   #1
ust
Senior Member
 
Registered: Mar 2003
Location: fasdf
Distribution: Debian / Suse /RHEL
Posts: 1,130

Rep: Reputation: 30
ftp script


I have a ftp script as below

ftp remote_server <<EOF
get *
bye
EOF



If I want to add a script ( called new_script ) to this ftp script --> after get * --> run the new_script --> bye , the new script should be as below , can advise what can i do ? thx



ftp remote_server <<EOF
get *
new_script
bye
EOF
 
Old 07-18-2008, 04:54 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
If the "new_script" contains ftp commands only (no other statements or comments inside it) you can do something like this
Code:
ftp remote_server << EOF
  get *
  $(cat new_script)
  bye
EOF
The shell does the command substitution before actually using the here document. So the content of new_script is executed as if it would have been written into the here document itself.
 
Old 07-18-2008, 04:59 AM   #3
tungvs
Member
 
Registered: May 2008
Distribution: Centos; Ubuntu; Fedora
Posts: 98

Rep: Reputation: 15
You can use "!new_script" to run the script outside the ftp shell.
 
Old 07-18-2008, 05:03 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Quote:
Originally Posted by tungvs View Post
You can use "!new_script" to run the script outside the ftp shell.
Good call. I didn't remember about that.
 
  


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
FTP script quest4net Linux - Newbie 4 04-08-2008 02:34 PM
Regarding FTP script chnlinux Linux - Newbie 2 07-17-2007 08:48 AM
FTP Script tommytomato Linux - General 28 07-14-2006 06:16 AM
Urgent Help: Perl FTP Script Using NET::FTP xboxter Programming 8 05-16-2005 07:57 PM
ftp script dlm4444 Linux - Networking 5 02-11-2004 12:41 AM


All times are GMT -5. The time now is 09:55 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration