曲径通幽论坛

 找回密码
 立即注册
搜索
查看: 4066|回复: 0
打印 上一主题 下一主题

here 文档使用实例 -- FTP 文件自动传输

[复制链接]

4918

主题

5880

帖子

3万

积分

GROAD

曲径通幽,安觅芳踪。

Rank: 6Rank: 6

积分
34395
跳转到指定楼层
楼主
发表于 2011-9-2 11:18:57 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
here 文档用来干嘛?
它主要将定义在它范围内的内容提交给交互式程序。这里演示一个使用 here 文档的使用实例,用来实现 FTP 文件的自动传输。命令如下:
$ ftp -i -v -n 121.15.145.7 <<END_FTP
user vh492377 123456
bin
cd www/bbs
put view.html
END_FTP
运行输出:
Connected to 121.15.145.7 (121.15.145.7).
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 2 of 50 allowed.
220-Local time is now 11:11. Server port: 21.
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Remote system type is UNIX.
Using binary mode to transfer files.
331 User vh492377 OK. Password required
230-User vh492377 has group access to:  vh492377
230 OK. Current restricted directory is /
200 TYPE is now 8-bit binary
250 OK. Current directory is /www/bbs
local: view.html remote: view.html
227 Entering Passive Mode (121.15.145.7,176,210)
150 Accepted data connection
226-File successfully transferred
226 0.054 seconds (measured here), 1.87 Mbytes per second
105229 bytes sent in 0.0344 secs (3062.81 Kbytes/sec)
221-Goodbye. You uploaded 103 and downloaded 0 kbytes.
221 Logout.
在 ftp 命令中:
-i 选项表示关闭交互式信息提示。

-n 选项表示限制 ftp 的自动登录,即不使用。如果是自动登录,那么 ftp 不用你输入用户名,而会自动去查找 .netrc 文件来寻找用户名和密码,如果没找着,那么它仍然会提示你输入用户名和密码。所以这里要使用 -n 选项禁止使用自动登录功能。

-v 选项表示要输出详细的连接信息。

另外注意用户名和密码是通过 user 命令来录入的,即 user 后面跟着 用户名 和 密码。登录成功后,下面就是你要操作的 FTP 指令了。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|曲径通幽 ( 琼ICP备11001422号-1|公安备案:46900502000207 )

GMT+8, 2025-5-4 04:44 , Processed in 0.076390 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表