Tech Talk Discuss PC Hardware, Software, Internet and Other Technology

unix: automating file transfers

Old 06-01-04, 08:34 AM
  #1  
DVD Talk Hero
Thread Starter
 
CRM114's Avatar
 
Join Date: Jun 2001
Posts: 42,731
unix: automating file transfers

Are there any unix/linux users here?

I'm looking for a way to move files around several unix machines automatically. i can use cron to schedule the movements but I'm not sure and can't find a simple way to script it. anyone?
CRM114 is offline  
Old 06-01-04, 11:14 AM
  #2  
DVD Talk Legend
 
Join Date: Jul 2000
Location: chokin' you out in less than 30 seconds
Posts: 10,634
using nfs? ftp? samba?
crankyman is offline  
Old 06-01-04, 01:51 PM
  #3  
DVD Talk Hero
Thread Starter
 
CRM114's Avatar
 
Join Date: Jun 2001
Posts: 42,731
Originally posted by crankyman
using nfs? ftp? samba?
Yes, but how would one script it?
CRM114 is offline  
Old 06-01-04, 07:46 PM
  #4  
DVD Talk Hero
 
jfoobar's Avatar
 
Join Date: Jun 2000
Posts: 37,659
You could use `rsync`:

http://samba.anu.edu.au/rsync/

It is a very cool utility.
jfoobar is offline  
Old 06-02-04, 11:47 AM
  #5  
DVD Talk Special Edition
 
Join Date: Jan 2001
Location: New York, N.Y.
Posts: 1,706
Originally posted by CRM114
Yes, but how would one script it?
It's really easy to write a "HERE" script using ftp.
i.e.


ftp -n << END_OF_FILE
open $HOSTNAME
user $USER pwd $PASSWD
put $FILENAME
quit
END_OF_FILE
timewaster is offline  
Old 06-02-04, 01:26 PM
  #6  
DVD Talk Hero
Thread Starter
 
CRM114's Avatar
 
Join Date: Jun 2001
Posts: 42,731
timewaster - is that just a shell script? what does this part do:

<< END_OF_FILE
CRM114 is offline  
Old 06-02-04, 01:37 PM
  #7  
DVD Talk Hero
Thread Starter
 
CRM114's Avatar
 
Join Date: Jun 2001
Posts: 42,731
I used your script timewaster. I replaced the $variables with my values and tried to run it. It looks like it gets to a point and then fails. Here's a transcript:

[nc-40:~] admin% ./test
Connected to XXX.com.
220 FTP server ready
331 Password required for joeblow.
530 Login incorrect.
Login failed.
local: testfile.txt remote: testfile.txt
530 Please login with USER and PASS
530 Please login with USER and PASS
530 Please login with USER and PASS
530 Please login with USER and PASS
221 Goodbye.
CRM114 is offline  
Old 06-02-04, 02:03 PM
  #8  
DVD Talk Platinum Edition
 
Join Date: Jan 2003
Location: Tennessee, USA
Posts: 3,515
remove the "pwd" from line 3.
taa455 is offline  
Old 06-02-04, 02:30 PM
  #9  
DVD Talk Hero
Thread Starter
 
CRM114's Avatar
 
Join Date: Jun 2001
Posts: 42,731
taa455 - Thank you. Works good. This is all I need for now. Thanks to timewaster for the initial post.

Does anyone know if I can do something similar using sftp?

JustinS - I've been looking at rsync for a while. Ultimately, thats the perfect utility for what I need it for. I tried it this afternoon again but can never seem to get rsync to run in daemon mode. I issued "rsync --daemon" but it never appears in the process list and my remote script fails. Oh well.
CRM114 is offline  
Old 06-02-04, 05:41 PM
  #10  
New Member
 
Join Date: Oct 2003
Posts: 7
For this sort of transfer, I like to use rsync via an ssh tunnel or scp. Either of these would let you use ssh rsa keys and not have to put your password in the script as plain text.

See the ssh man pages for how to set up the rsa key, but the quick version is if you generate a rsa key without a password, and place the public key into the destinations .ssh/authorized_keys file, you login automatically.

To use rsync via ssh, and avoid most of the daemon issues, have the environmental RSYNC_RSH=ssh.

An example script:
#!/bin/bash
export RSYNC_RSH=ssh;
rsync -az /original [email protected]:/destination;
hallsa is offline  

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 On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive Advertising Cookie Policy Privacy Statement Terms of Service

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.