File transfer using Linux or Unix
There are many file transfer methods for both Linux, Unix and Windows environments, but I am going to focus on the command line programs on the Linux and Unix platforms. Windows users can use most of these if the command line programs are installed.If you need to transfer files between your computer and a remote computer foo.com here is what you should do..
| my computer current dir: /home/wolf/perl file to upload to foo.com: wolf.pdf => file to download from foo.com: arul.ps <= |
remote computer (foo.com) remote directory: /home/arul/backup |
Also check out my Shell Script to automate file transfer using FTP.
FTP (file transfer protocol)
This is mostly used to copy files between computers. It doesn't support compression. It is also not encrypted. This is how to transfer files.To connect to foo.com
ftp foo.comYou will have to enter your username and password when prompted.
If the file being transferred is a binary file (yes, PDF and PS are binary files), type the following.
binaryTo upload your file wolf.pdf to the directory in foo.com
cd /home/arul/backup put wolf.pdfTo download the file arul.ps from the directory in foo.com
get arul.psIf you have multiple files, use
mget instead of get and mput instead of put.
To quit, type bye. This is just the basic file transfer using FTP. To check all the options using FTP, type man ftp from your shell prompt.
SFTP (secure file transfer protocol)
SFTP is an interactive file transfer program, similar to FTP, which performs all operations over an encrypted secsh transport. If you are a Windows user, you will need a secure file transfer program like WinSCP program.To connect to foo.com here is what you should do.
sftp foo.comYou will have to enter your username and password when prompted.
To upload your file wolf.pdf to the directory in foo.com
cd /home/arul/backup put wolf.pdfTo download the file arul.ps from the directory in foo.com
get arul.psIf you want to download multiple files, say all PDF files,
get *.pdfTo quit, type
exit. This is just the basic SFTP. To check all the options using SFTP, type man sftp from your shell prompt.
SCP (secure copy)
SCP is used for single file transfers unlike SFTP or FTP, where once connected, you can carry out any number of transfers.To upload the file wolf.pdf to the /home/arul/backup in the remote computer foo.com here is what you should do. Lets say the username and password for connecting to foo.com are us3r and p4ssword respectively, read ahead.
scp wolf.pdf us3r@foo.com:/home/arul/backup/You will be prompted for your password, which you should enter. It uploads the file and quits automatically.. all in one operation.
To download the file arul.ps from the remote directory, here is what you must do.
scp us3r@foo.com:/home/arul/backup/arul.psIf you want to upload the entire perl directory (recursively) here is what you do.
scp -r /home/wolf/perl us3r@foo.com:/home/arul/backup/
wget
To download the index.html page of gnome.org, here is what you type.wget http://www.gnome.org/index.html... and you have the index.html page on your current directory :)
If you want to rip the website upto 3 levels,
wget -r -l 3 http://www.gnome.org
Shell Script to automate upload using FTP
I wrote this simple shell script to automate upload and download of files.. just customise it according to your use.
#!/bin/bash
HOST='foo.com'
USER='us3r'
PASSWD='p4ssword'
ftp -i -n $HOST <<Arul
user ${USER} ${PASSWD}
binary
cd /home/arul/backup
put wolf.pdf
get arul.ps
quit
Arul
Last Update: 2005








