The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-20-2001
cfoxwell cfoxwell is offline
Registered User
  
 

Join Date: Mar 2001
Location: UK
Posts: 20
Question Here Doc (I think!)

Can someone explain to me how a here doc works.

I thought it was something like this

<<EOF
command
command
command
EOF

What I am trying to do is put a ftp commands into my shell script, and I've been told that I need to use a here doc for it.

Can anybody shed some light on this please.
  #2 (permalink)  
Old 08-20-2001
PxT's Avatar
PxT PxT is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909

Code:
ftp << EOF
open ftp.yoursite.com
bin
get /pub/file
quit
EOF


Use in conjunction with a .netrc file to completely automate the session.
  #3 (permalink)  
Old 08-20-2001
kapilv kapilv is offline
Registered User
  
 

Join Date: Nov 2000
Location: India
Posts: 83
Quote:
Originally posted by PxT

Code:
ftp << EOF
open ftp.yoursite.com
bin
get /pub/file
quit
EOF


Use in conjunction with a .netrc file to completely automate the session.
The 2 less than (<<) signs indicate that to the shell that a here document follows . The starting EOF indicates the opening delimiters and the ending EOF indicates the ending delimiters. The delimiters used here are not fixed, you can use a plus sign(+), an exclamation mark (!), EOF as used above etc etc...
Everything between these 2 delimiters is send as input to the process (Here it's ftp).

  #4 (permalink)  
Old 08-21-2001
cfoxwell cfoxwell is offline
Registered User
  
 

Join Date: Mar 2001
Location: UK
Posts: 20
Re here doc

Nice one thanks for the info.

Just one little extra question.

If I'm using FTP, and I want to sign in as another user other than myself with a password, does it work the same, or do I have to do something else.. Or is that when the .netrc file comes in so I don't need a password..
  #5 (permalink)  
Old 08-21-2001
kornshellmaven kornshellmaven is offline
Registered User
  
 

Join Date: Apr 2001
Posts: 25
ftp -n -v hostname <<-ENDTAG
userid
password
the rest of your ftp commands
ENDTAG
  #6 (permalink)  
Old 08-22-2001
LivinFree's Avatar
LivinFree LivinFree is offline Forum Advisor  
Goober Extraordinaire
  
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Quote:
Originally posted by kornshellmaven
ftp -n -v hostname << ENDTAG > session.log
userid
password
the rest of your ftp commands
ENDTAG
That will drop all of your output into a log, in this case called "session.log".

HTH
  #7 (permalink)  
Old 08-22-2001
kapilv kapilv is offline
Registered User
  
 

Join Date: Nov 2000
Location: India
Posts: 83
Re: Re here doc

Quote:
Originally posted by cfoxwell
Nice one thanks for the info.

Just one little extra question.

If I'm using FTP, and I want to sign in as another user other than myself with a password, does it work the same, or do I have to do something else.. Or is that when the .netrc file comes in so I don't need a password..
yes it will work the same provided you know the username and it's password.


Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0