The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 11:10 AM
SSH Problem auth problem budrito UNIX for Advanced & Expert Users 1 03-17-2004 10:12 AM

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 06-06-2008
kdyzsa kdyzsa is offline
Registered User
  
 

Join Date: May 2008
Posts: 14
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 (permalink)  
Old 06-06-2008
jaduks's Avatar
jaduks jaduks is offline
Registered User
  
 

Join Date: Aug 2007
Location: Assam,India
Posts: 167
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 (permalink)  
Old 06-06-2008
kdyzsa kdyzsa is offline
Registered User
  
 

Join Date: May 2008
Posts: 14
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?
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 12:08 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