Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interesting FTP Problem

Status
Not open for further replies.

GOSCO

Technical User
Sep 26, 2000
134
0
0
GB
I want to retrieve a file from a remote machine as routine. Is there anyway I can use ftp with the correct extensions to :

1. FTP to a server.
2. Login.
3. Run the get command to retrieve a file.

If anyone knows how to do this they have a friend for life!

Andy
++
 
GOSCO:

Your request is discussed on 05/22 over in the Unix Scripting Forum. Here's Robert Jordan's post from that thread:



# ftp server/login info
FTP_HOST=some.host.name
FTP_USER=user_name
FTP_PASSWD=password

# local directory
LOCAL_DIR=

# remote directory
REMOTE_DIR=/prod/int/home/intranet/employee_survey

# file
XMT_FILE=

# command
COMMAND=get #put or get

ftp -n $FTP_HOST<<END_SCRIPT
quote USER $FTP_USER
quote PASS $FTP_PASSWD
$COMMAND $LOCAL_DIR/$XMT_FILE $REMOTE_DIR/$XMT_FILE
quit
END_SCRIPT

Robert G. Jordan
Unix Sys Admin
Sleepy Hollow, Illinois U.S.A.
 
Another way is to use .netrc file,
where one can put following:
machine hostname
login username
password pwd
put from_file to_file
quit

So, when you say
ftp hostname
it would automatically login and put a file there.

Remember, that you are revealing username/passwd, so be carefull.

Michael.
 
Excellant, thanks for your help guys. Ive just written a script that dials into a list of sites for me, grabs a file which tells me whether the backup was ok. Then sorts it in a nice easy to read list? Nice or what!

I wouldn't have been able to do it without you...

Andy
[medal]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top