Вы находитесь на странице: 1из 3

file transfer using gnu/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 remote computer (foo.com)
current dir: /home/wolf/perl remote directory: /home/arul/backup
file to upload to foo.com: wolf.pdf =>
file to download from foo.com: arul.ps <=

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.com
you 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.
binary
to upload your file wolf.pdf to the directory in foo.com
cd /home/arul/backup
put wolf.pdf
to download the file arul.ps from the directory in foo.com
get arul.ps
if 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.com
you 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.pdf
to download the file arul.ps from the directory in foo.com
get arul.ps
if you want to download multiple files, say all pdf files,
get *.pdf
to 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.ps
if 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

Вам также может понравиться