Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want a file to be uploaded daily to remote server using automated ftp command. Can someone please help me on this below command to check whether it's right or wrong?

curl -Tu username:password /path/to/dir/*(om[1]) sftp://sftp.example.com/remote/dir

where

  • username:password is my own username and password.

  • /path/to/dir/*(om[1]): to get the latest(updated) file from my local dir

  • sftp://sftp.example.com/remote/dir: secure file transfer

share|improve this question
2  
Do you get any errors when you run this, what have you done to get the answer so that you know first if it is right or wrong? –  vgoff Nov 21 '12 at 1:42
    
OP, please accept my answer if you found it acceptable. –  laebshade Dec 9 '12 at 22:24
add comment

1 Answer 1

Why not rsync instead? You may have to install it (use your package manager), but it's made for this kind of thing.

RSYNC_PASSWORD='password' rsync -rtv /path/to/dir/ username@sftp.example.com:remote/dir

-r will recursively rsync, -t preserves time stamps so existing files aren't re-uploaded (effectively), and -v is verbose.

If you create and copy your ssh public key, you won't need to do the RSYNC_PASSWORD='password' part.

If you don't have a public/private key combination, run:

ssh-keygen

Then

ssh-copy-key-id username@sftp.example.com

This assumes your remote server supports connecting and updating the $HOME/.ssh/authorized_keys file; otherwise, you'll have to manually upload the authorized_keys file with your public key.

This assumes you're running a recent version of linux. Unix systems like Mac OS don't have the ssh-copy-key-id. Here's some more information on generating and installing your public key on a remote host:

http://www.ece.uci.edu/~chou/ssh-key.html

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.