`
61party
  • 浏览: 1053994 次
  • 性别: Icon_minigender_2
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

FTP命令简介

 
阅读更多
<!--[if IE]> <?XML:NAMESPACE PREFIX = GDOC /> <![endif]--> FTP Guide

 A short guide to using FTP
============================

# FTP (short for File Transfer Protocol) is extremely useful for transferring
# files to and from another site.

# Usage:
% ftp site_name
(enter user id)
(enter user password)

# Example:
% ftp gantt.stanford.edu
ftp> Connected to gantt.stanford.edu
220 gantt.stanford.edu FTP server (Version 4.187 Wed Nov 28 17:08:58 EST 1990) ready.
Name (cn.ecn.purdue.edu:aec99): aec99
331 Password required for aec99.
Password: xxxxxxxx
230 User aec99 logged in.
ftp> ... and you are in.

# Usage (commands):
ftp> ls <- to list files in foreign host.
ftp> dir <- to list files in foreign host including date, size, etc.
ftp> !command <- to run commands at the host you are on., e.g. !ls
ftp> cd <- to change directory
ftp> asc <- to set to text mode for transfer (for text files only)
ftp> bin <- to set to binary mode for transfer (for everything else - reccommended)
ftp> bye <- to exit

# Transferring files:
# To transfer a file, use 'get' and 'send'. In the case of a binary file, the
# command 'bin' has to be typed first to prepare the host to receive the file.
# If not, strange things happen... (to the file, that is). Text file can be
# transferred without problem using either text or binary modes.

# Usage:
ftp> get file_name (getting a text file)

ftp> send file_name (sending a text file)

ftp> bin (getting a binary file, e.g. xxx,gif, xxx.exe, elm, etc)
221 set type to I <- host response
ftp> get file_name

ftp> bin (sending a binary file)
ftp> send file_name

# Sometimes, mass retrieval can be done by using 'mget'

# Usage:
ftp> mget wild_card

# Example:
ftp> mget new* (to get any file which start with 'new'.)

# To exit...
ftp> bye

# Publuc-access FTP-sites:
# There are a number of public-accessible FTP-sites around InterNet. Many of
# them contain useful softwares (and even games and nice GIFs!). These sites
# can be accessed as the following:

% ftp site_name
(user login:) anonymous
(user password/guest ID:) your own LOGIN@MACHINE

# Example:
% ftp ftp.cica.indiana.edu
ftp> Connected to ftp.cica.indiana.edu.
220 ftp FTP server (Version 6.16 Thu May 7 14:43:04 EST 1992) ready.
Name (ftp.cica.indiana.edu:wai): anonymous <------
331 Guest login ok, send e-mail address as password.
Password: wai@sage.cc.purdue.edu <------
230-**
230-** You have reached ftp.cica.indiana.edu [129.79.20.84] at
230-** the Center for Innovative Computer Applications (CICA) at
230-** Indiana University in Bloomington, Indiana USA.
230-** .... [lost of intro deleted]
230-**
230-
230 Guest login ok, access restrictions apply.
ftp>

# Here is a short list of only few of the many FTP-sites around:

# ftp.cica.indiana.edu - Win3 drivers & programs
# me.uta.edu - Engineering programs
# media-lab.media.mit.edu 18.85.0.2 Misc items
# monu6.cc.monash.edu.au 130.194.32.106 PC softwares + Win3 drivers & programs
# pit-manager.mit.edu - Usenet infos, newsgroups faqs, etc.
# procyon.cis.ksu.edu - PC softwares and MS-DOS based Unix progs.
# utsun.s.u-tokyo.ac.jp 133.11.11.11 Misc items.
# uxc.cso.uiuc.edu 128.174.5.50 Misc usenet items.
# wuarchive.wustl.edu 128.252.135.4 Misc MS-DOS items.
# garbo.uwasa.fi - PC and Windows softwares (good)

# Have fun!

==================================================================================================================

HOW TO FTP A FILE:

Here are the steps you use to ftp a file.
rev. vmv 5/27/99
rev. vmv 03/01/01
rev. vmv 04/11/01

A) TO FTP TO A NODE ON WHICH YOU HAVE AN ACCOUNT:
FOR WINCENTER ACCOUNT TO UNIX, or
FOR WINCENTER TO WINCENTER, GO TO (1)
FOR AN ANONYMOUS LOGIN, GO TO (2)

In a window, cd to the directory where you want the files to be put in,
in your account. Or where the files are that you are sending to another
account.

> cd myspecialdir
> ftp nodename (ftp cadwhs01)

login with username and password (you have to have an account on the
node that you are getting a file from
or access privileges unless it is an
anonymous account.

1) FOR WINCENTER TO UNIX or WINCENTER TO WINCENTER

Start up the Citrix ICA Client for IRIX

% wincenter

Go to Entry/Connect
OK
Go to the Start Button/Programs/Command Prompt
cd to the directory you want the files to either go to or go from.

EXAMPLE:
U:/users/vivianv> cd PPDPamphlet
U:/users/vivianv/PPDPamphlet> ftp cadwhs01 (UNIX server where my account is)
User (cadwhs01.fnal.gov:(none)): vivianv
Password required for vivianv
Password ************
User vivianv logged in.

ftp> cd dirwhere_the_files_are_located_or_copied_to

ftp> get name_of_file.ps OR
ftp> put name_of_file.ps

* Note when transferring files:
Drafting files need to be sent binary so you must specify "bin" before
the transfer. Text files are send "ascii", postscript doesn't matter.

* If you receive an error when ftping from wincenter to wincenter, you
will have to transfer your files from your first wincenter account to
an area on your UNIX account initially, and then ftp them from your
second wincenter account from the UNIX account.
-----------------------------------------------------------------------------
2) TO FTP TO A NODE WITH AN ANONYMOUS LOGIN:

> cd myspecialdir
> ftp ftp.sdrc.com (the anonymous site)

login in with "anonymous" and the password is your email address
ie. jimbo@fnal.gov

Once in, you can cd to the directory where the files are you are trying to
get or send. You can do a dir to see where you are and where you want to go.

Once you are in the proper directory or area the following tells the proper
syntax that should be used when transferring file.
-----------------------------------------------------------------------------
A) IF YOU ARE GETTING ONE FILE:

ftp> cd dirname (cd to the directory where you are to get your file, like "pub")
ftp> bin (makes sure all transfers are in binary format)
(the only thing that uses ascii is a text file)
ftp> get filename (ie. get assembly.dwg)

IF YOU ARE GETTING LOTS OF FILES:

ftp> bin
ftp> mget *.dwg (it will ask you if you want to get each file
individually and you type either y or n.
-----------------------------------------------------------------------------
B) IF YOU ARE SENDING ONE FILE:

ftp> cd dirname (cd to the directory where you are to put your file, like "pub")
ftp> bin
ftp> put filename (ie. put tankassy.dwg)
-----------------------------------------------------------------------------
C) IF YOU ARE SENDING LOTS OF FILES:

ftp> bin
ftp> mput *.ps (put the extension of the files that you are putting in or
(use * if there are too many different kinds)

NOTE:
You can specify the file be named differently in your unix account if
you are getting from an NT or PC. They typically have names that
unix doesn't like, like assy$1.dwg or assy&hgr.dwg or name with spaces,
like Hanger and Assy.dwg. Unix recognizes symbols as what is used
for script writing and programming and is unable to parce spaces.

INSTEAD USE THIS SYNTAX:

ftp> bin
ftp> get filename newfilename (get assy$1.dwg assembly1.dwg)
to change the file name when it is copying to your account.

*DO NOT USE mget THIS WAY, IT DOESN'T WORK.
-----------------------------------------------------------------------------
D) TO QUIT:

ftp> ftp quit
-----------------------------------------------------------------------------
EXAMPLE:

You are sending an archive file to sdrc because you can't read it or
there is some other problem. They tell you the name of their ftp site
is:
"ftp.sdrc.com", your username is
"customer" and your password is
"dirtft2p"
and to put your archive file in the directory named
"incoming".
Here are the steps you would take.

> ftp ftp.sdrc.com
> customer
> dirtft2p
ftp> cd incoming
ftp> bin
ftp> put scrambled_shaded_tube.arc
ftp> quit

=================================================================================================================

ASCII Mode & Binary Mode
FTP has two modes to transfer files: ASCII mode and Binary mode.

ASCII is a 7bit format, the last bit is always 0, and so only 7 bits are transferred in ASCII mode the 0 being appended to create the full byte.

In binary mode this is not the case and all 8 bit are transferred. If the file bing transferred was ASCII to begin with you won't see a problem, but if you transfer a binary as ascii it will become corrupted.

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics