FTP Problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP Problem
# 1  
Old 06-06-2008
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

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.
# 2  
Old 06-06-2008
Your script looks good to me.

Code:
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
put $FILE
quit
END_SCRIPT

Don't confuse with END_SCRIPT , as its just a eof corresponding to the previous <<END_SCRIPT entry in the "ftp -n .." line. You can use any tag.
Since you are doing "put $FILE", the file will be transferred(put to the remote $HOST) provided the ftp connection is proper(ftp credentials) and $FILE is present in the dir from where you are running this script. Hope this helps.

//Jadu
# 3  
Old 06-06-2008
Hm

I want to know how to switch servers?

Since I would be placing this script in a program. The script would have to log on to said server, enter username and pass, go to directory get the file and log on to another server, enter username and pass, go to that directory and paste the file? Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

ftp problem?

Dear All I cannot ftp to my RedHat server from MS Windows machine ,but ping and telnet are ok. I checked as the following : #chkconfig tftp on #setup After enabling tftp service, still the ftp is not ok but ping & telnet are ok. Can you please help me? Thank you (8 Replies)
Discussion started by: hadimotamedi
8 Replies

2. Shell Programming and Scripting

ftp problem

Hello, I have a very simple script that put a file in server ftp #!/bin/bash var="ITW-trail-templiers-samedi" cd /Users/$USER/Desktop ftp -n >&1 << EOF open server quote user "user" cd oberon binary put "$var" bye EOF I have error : 200 Type set to IMAGE. remote:... (2 Replies)
Discussion started by: protocomm
2 Replies

3. Shell Programming and Scripting

FTP Problem

Hello experts, I've got the following script that is supposed to FTP a file to another box. #!/usr/bin/ksh while read line do HOST=`echo "$line" | cut -d" " -f1` USER=`echo "$line" | cut -d" " -f2` PASSWD=`echo "$line" | cut -d" " -f3` PATH=`echo "$line" | cut -d" " -f4` done <... (5 Replies)
Discussion started by: King Nothing
5 Replies

4. Shell Programming and Scripting

problem in FTP

i m able to login to Unix box from window's cmd can anyone tell me how to run a script from window cmd using ftp ? the script is in unix box and i need to run from windows CMD using ftp (2 Replies)
Discussion started by: ali560045
2 Replies

5. Shell Programming and Scripting

problem with ftp:

i have got 2 servers in unix(IBM AIX 5.3) namely below. test1 production1 i m trying to do ftp from test1 to production1. ------------------------------------------------------------ below the script called naveed1.sh which lies in test1,also it have two files called ... (2 Replies)
Discussion started by: ali560045
2 Replies

6. HP-UX

FTP problem

We recently moved offices and checked our network ID. I have configured all the files that I am familiar with and am able to telnet and ping from my pc but I am unable to ftp. Any suggestions...Thanks (5 Replies)
Discussion started by: andrewd
5 Replies

7. Solaris

FTP problem

Hi Guys, Got problem when I tried to get files from Solaris server to my PC. The connection transfer was using FTP and the connection was made from the solaris server to my PC. Here's what happened when the file transfer being made: # ftp 10.192.23.230 Connected to 10.192.23.230. 220... (9 Replies)
Discussion started by: raskita
9 Replies

8. Shell Programming and Scripting

Ftp problem

hi i have written a shell to automate the ftp process for the particular file.iam getting errors when try to ftp it.And i am cant get why the lcd is not being taken properly as it is taking during runtime.can anyone give me a solution here its my code DATE=`date '+%d_%m_%Y'`... (1 Reply)
Discussion started by: cskumar
1 Replies

9. UNIX for Dummies Questions & Answers

FTP problem. please help

can someone tell me how I can deal with a problem am having concerning users that are faliing to use one of the shells specified in the /etc/shells file. as a result, am told, these users are bound fail to connect via FTP. i know i goto check the /etc/shells file on the target host but what... (5 Replies)
Discussion started by: TRUEST
5 Replies

10. UNIX Desktop Questions & Answers

ftp problem

I use FTP in a shell script to transfer the files to a remote server. Sometimes the program hangs without returning any errors after the command ftp server_name How do you detect from within the shell that something is wrong? How do you trap the errors returned by ftp command? Any help... (3 Replies)
Discussion started by: marusia
3 Replies
Login or Register to Ask a Question