LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   FTP Problem (https://www.linuxquestions.org/questions/programming-9/ftp-problem-647347/)

kdyzsa 06-06-2008 01:07 AM

FTP Problem
 
Hi, I'm currently stuck in this ftp problem. Normally I just type ftp at the command line, but now I have to implement it in a code.

Basically I have to transfer a .txt file from a server, let's say hkhpdv13 in the folder of /home/sap/ftp to another server hkhpdv15 in the folder /home/sap/ftp/text. Both of these servers has a different user name and password

I've researched and saw this sample code.

#!/bin/sh
HOST='ftp.users.qwest.net'
USER='yourid'
PASSWD='yourpw'
FILE='file.txt'

ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
quit
END_SCRIPT
exit 0

I don't really know where they get the END_SCRIPT, and also how they transferred to another server there. Help in explaining please?

I want to know how to transfer a file if it switches from one server to another. As well as how do I know if the file transfer was successful or not, is there a code in there? or something any help would be appreciated.

weibullguy 06-06-2008 04:51 AM

The END_SCRIPT is marking the end of the ftp session that begins with the line
Code:

ftp -n $HOST <<END_SCRIPT
The HOST variable is the remote host. The script presumes that you will be in directory containing FILE on the local machine when you execute the script.

You may want to check out C-Kermit if you will be doing scripted ftp transfers.


All times are GMT -5. The time now is 10:32 PM.