分享
 
 
 

useatext-baseftp

王朝other·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

Using a text based ftp client is not truly linux specific, however there is a chance that you may need to download a file from an ftp server and don't want the overhead of installing a GUI based ftp client nor using a comparitively bloated webbrowser. Maybe you want to use some of the power and features available in a ftp client that for whatever reasons aren't supported in the webbrowsers.

Most text based ftp clients, regardless of the operating system they run on, use the same command set that you type in to instruct the client on what it is you want it to do - generally speaking you should be able to learn how to use a text based ftp client once and use that knowledge many times. I'm writing this under the assumption that you are using linux to connect to ftp servers.

1. Logging in.

Firstly you will need to open a connection to the ftp server:

$ftp

ftp> open edge

This opens a connection to the ftp server running on my linux box called 'edge' and could also have been done by typing

$ftp edge

After the client has connected to the server you will see a login banner and a username prompt. After typing in the user name you will be prompted for a password - if you want to log in to an 'anonymous' account you should enter youremail address as the password.

To log out, type 'quit'.

If you use ncftp as the ftp client and it has automatic anonymous logins enabled (which it does by default), then you won't be prompted for a username amd password.

2. Directories.

2.1 Initial directory.

If you log in as anonymous then your initial working directory will be the root dierctory, otherwise your initial working directory will be the home directory of the user that you logged in as.

2.2 Changing directories:

You will need to move to the appropiate directory once you have logged in. Doing this is the very same as changing directories within linux - with the 'cd' command. Using 'cd' will move you around the directory structure of the ftp server, if you need to move around the directories of the PC that you are connecting with, then you should use the 'lcd' command.

Depending on which operating system the ftp server is running on it will most likly be case sensitive with regards to file and directory names.

2.3 Directory Listings.

As with Unix, the 'ls' command should be used if you want to get a general listing of what files are in the remote working directory.

There's a particular twist though, if you want a 'long' directory listing similar to what you get with 'ls -l' you can either type 'ls -l' itself or be slightly lazy about it and type 'dir'.

If you would like to keep a local copy of the directory listing, the 'mls' command should be used.

With regard to using mls, you have to specify which remote directory the listing should be of, so if you want a listing of the current directory you have to type '.' as the name of the directory.

You then have to specify the local file that you want the directory listing to be saved to and type 'y' in response to the 'output to local file' question that follows.

2.4 Modification date of a file.

The 'modtime' command is useful for when you need to know when a remote file was last modified.

3. Running a 'shell' command.

It can be useful at times to run a shell command from within an ftp connection. This is done by first typing an exclamation mark (!) followed by the command itself.

I do this quite often to ensure that I am in the correct local directory as it helps to make certain that I am not going to to overwrite a local file. To do this, you should type:

ftp> !pwd /home/ken

You can also use '!' on it's own to get to the command prompt without logging out from the ftp session. You can get back to the ftp prompt by typing 'exit'.

4. Transferring files.

Okay, so now that you know how to log in and change directories the next thing that you need to learn is how to transfer files.

Before you get around to transferring a file though it is important that you are in the correct transfer type.

4.1 Transfer type.

There are two transfer types that can be used to transfer files; ascii and binary.

To see which transfer type is currently active, use the 'type' command.

ftp> type

Using binary mode to transfer files.

ftp> ascii

200 Type set to A.

ftp> type

Using ascii mode to transfer files.

ftp> binary

200 Type set to I.

ftp> type

Using binary mode to transfer files.

As seen in the example above, type 'ascii' to change to the ascii type and 'binary' to change to the binary type.

4.2 Copying files.

To get a copy of a file from the server to the local computer you use the command 'get'.

Tp put a copy of a local file onto the sever you use the command 'put'.

4.3 Copying multiple files.

If you need to copy a number of files of the same transfer type from one remote directory to a local directory you can use the command 'mget', similarly 'mput' should be used to transfer a number of files of the same type onto the server.

You can be as specific or as general in your use of 'mget' or 'mput' as you like.

For example 'mget *' means that all remote files (both binary and ascii) will get copied down from the server. Similarly 'mget foo*' means that all files starting with 'foo' will be copied down from the server.

Each time that you use mget or mput you will be prompted to confirm the transfer. Typing anything other than 'n' means the file will be copied.

You can quit out of mget or mput and remain in the ftp session by pressing ctrl-c.

4.4 Resuming a 'get'.

One of the nice advantages that you get by using an ftp client over a web browser that supports the ftp protocol is that, if your connection to the server breaks for whatever reason, you can get the ftp client to start over again from where it left off. This is done by using the 'reget' command.

4.5 Visual confirmation.

If you are copying a large file and would like some form of visual indication of progress then the 'hash' command, which causes the hash mark (#) to be printed for each segment of the file which has been copied, will be of use to you.

You should use the 'hash' command before copying the file for which you want the visual indication.

5. Deleting files.

Once you have made a local copy of a file from the server you may want to delete the original file that you copied. Naturally, this will only work if you have the appropriate permissions to delete the file.

To do this, use the 'delete' command.

if you have a number of files to delete, I'd suggest you use the 'mdelete' command which can be aborted by pressing ctrl-c.

6. Macros.

I doubt this facility is available in all text based ftp clients but it is far too useful to not mention.

You can use 'macdef' to combine several commands into a macro, so that for example if you find that you always follow a 'pwd' with a '!pwd' then you could combine these into a macro called '2pwd' and use that instead. For example:

ftp> macdef 2pwd

Enter macro line by line, terminating it with a null line

pwd

!pwd

<Enter>

To indicate that you want to use a macro instead of a standard command you have to preceed the name of the macro with a dollar sign ($). For example:

ftp> $2pwd

pwd

257 "/home2/wolfhaven" is current directory.

!pwd

/home/ken

This is a very trivial example but you should be able to see how to apply this to a larger sequence of commands.

X. More Information.

If you would like to learn more of the ftp client's commands, I'd suggest you use the help command and also man ftp at the command prompt. Using 'help' on its own will present you with a list of commands that the ftp client supports, to get details of what a specific command does then add it as a parameter to the help command. For example:

ftp> help verbose

verbose toggle verbose mode

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有