sftp autologin is working but ...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sftp autologin is working but ...
# 1  
Old 07-17-2012
Java sftp autologin is working but ...

Dears,

I am new to linux scripting and I was look for a way to auto login to a server using sftp to download a file.
I found one and it is working fine. But i don't know the meaning of <<EOF in the code. Any one explain it to me:

Code:
#!/bin/sh  
HOST=yourservername
 USER=yourusername 
PASS=yourpassword  

echo "sftping file ..."  

lftp -u ${USER},${PASS} sftp://${HOST} <<EOF 
cd /tmp 
get tmpfile 
bye 

EOF  

echo "done"

# 2  
Old 07-17-2012
It's meaning is in a "here-document".

Your shell man-page should describe the construct for you.

Quote:

Here Documents
This type of redirection instructs the shell to read input from the current source until a line containing only word (with no trailing blanks) is seen.
All of the lines read up to that point are then used as the standard input for a command.

The format of here-documents is:

<<[-]word
here-document
delimiter

No parameter expansion, command substitution, arithmetic expansion, or pathname expansion is performed on word. If any characters in word are quoted,
the delimiter is the result of quote removal on word, and the lines in the here-document are not expanded. If word is unquoted, all lines of the here-
document are subjected to parameter expansion, command substitution, and arithmetic expansion. In the latter case, the character sequence \<newline> is
ignored, and \ must be used to quote the characters \, $, and `.

If the redirection operator is <<-, then all leading tab characters are stripped from input lines and the line containing delimiter. This allows here-
documents within shell scripts to be indented in a natural fashion.
This User Gave Thanks to Scott For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Put -r is not working in SFTP

Hi Folks, I am trying to copy a directory along with sub-directories to SFTP server. I have connected to SFTP and tried to run the below command: sftp> get -r abc/* It is throwing the error Invalid flag -r Can you please let me know the ways to copy a directory from Local to SFTP ... (1 Reply)
Discussion started by: kirans.229
1 Replies

2. Red Hat

Sftp command not working

What is wrong with this sftp command being used in one line: sftp /Data/SEmisstn.gz lsmsadit@144.226.213.23:/test/lsms.SEmisstn.gz The ssh key is already setup. The node is valid and i can ssh to it as well as do a manual step by step sftp to the server. However, for some odd reason, i... (10 Replies)
Discussion started by: mrn6430
10 Replies

3. Shell Programming and Scripting

Shell : sftp autologin not working ...

Hi folks, for sftp autologin, while browing in unix.com forums.. I got the below code. I tried to execute that code but no luck. #!/bin/sh HOST=yourservername USER=yourusername PASS=yourpassword echo "sftping file ..." lftp -u ${USER},${PASS} sftp://${HOST} <<EOF cd /tmp get tmpfile... (7 Replies)
Discussion started by: scriptscript
7 Replies

4. Solaris

Why is sftp working but ftp not

I am not very familiar with the use of FTP, and trying to run it I found out that standard "ftp" is not working" but "sftp" is. If sftp is allowed will that block ftp ? and if so where is this set ? I thought there is no relationship, is that right ? If so look here: inetadm | grep ftp enabled... (11 Replies)
Discussion started by: manni2
11 Replies

5. UNIX for Advanced & Expert Users

SFTP Not Working With CRON

Hello - I have a production stream that is scheduled with cron to run each Monday morning. The jobs in the stream perform tasks including FTP get, load to a DB table, and report processing. About a month ago I was directed to begin using sftp in these jobs and since then the jobs... (12 Replies)
Discussion started by: PatrickPurfield
12 Replies

6. UNIX for Advanced & Expert Users

SFTP not working in the background

I'm modifying some code to SFTP files because the remote servername and user are changing. The keys have been correctly installed and I'm using the -B option to automate the actions following connection e.g. cd, put etc. This is all working nicely. However, when I wrap this up to call it from a... (0 Replies)
Discussion started by: JerryHone
0 Replies

7. Shell Programming and Scripting

Automate SFTP is not working

Hi All:cool:, i tried to automate SFTP process after passwordless authendication. Stil i am getting error... Can anyone help.... ------------------- sample code below ------------------- sftp -v $mdskk@100.4.4.75 << EOF cd /data mget *.tar.gz bye EOF... (2 Replies)
Discussion started by: senthil_seera
2 Replies

8. UNIX for Dummies Questions & Answers

sftp not working as cronjob

hi, I have a script that will automatically login into a server and get a file. it is working fine if i run it on a command line. however, when i tried to run it as a cron job, it is not working. what should i do? set timeout -1 spawn /usr/bin/sftp user1@server1 match_max 100000 expect... (3 Replies)
Discussion started by: tungaw2004
3 Replies

9. Shell Programming and Scripting

SFTP not working in cron

Hi, I have a simple script that is trying to put a file that resides on a local machine to a remote machine. It runs fine manually but does not complete when scheduling to run in cron. Here is what the script looks like. Any idea what I am doing wrong here? #!/bin/ksh cd /path sftp... (4 Replies)
Discussion started by: ewilson0265
4 Replies

10. UNIX for Dummies Questions & Answers

sftp/scp autologin

Ive have 2 unix machines i need to transfer files from one to the other. Im trying to use either sftp or scp as ftp is out of the question. Ive created the RSA key on one machine and copied it across but im still prompted for a password. Assume this is due to the fact that im not using the same ID... (8 Replies)
Discussion started by: devid
8 Replies
Login or Register to Ask a Question