免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2581 | 回复: 5
打印 上一主题 下一主题

perl 能否不使用net::ftp模块而直接像shell那样使用ftp命令 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-09-03 09:58 |只看该作者 |倒序浏览
我想能不能不使用perl的net::ftp模块,使用ftp自己的cmd命令,就像使用shell一样,

ftp -n $HOST <<!
quote USER $USER
quote PASS $PASSWD
binary
cd /
prompt
ls -l file
bye
!

perl能够也这样使用呢

论坛徽章:
0
2 [报告]
发表于 2010-09-03 10:20 |只看该作者
当然可以。

不过为什么不用shell?

论坛徽章:
0
3 [报告]
发表于 2010-09-03 10:42 |只看该作者
回复 2# longbow0


    要在windows平台下使用,本来shell的一个版本已经写完了,用net::ftp,遇到不少问题,请问直接用ftp命令怎么样使用?就像直接使用ls -lt把文件和目录列表保存本地文件

论坛徽章:
0
4 [报告]
发表于 2010-09-03 11:20 |只看该作者
windows 的 ftp 参数

  1. c:\> ftp --help

  2. Transfers files to and from a computer running an FTP server service
  3. (sometimes called a daemon). Ftp can be used interactively.

  4. FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [-A] [host]

  5.   -v             Suppresses display of remote server responses.
  6.   -n             Suppresses auto-login upon initial connection.
  7.   -i             Turns off interactive prompting during multiple file
  8.                  transfers.
  9.   -d             Enables debugging.
  10.   -g             Disables filename globbing (see GLOB command).
  11.   -s:filename    Specifies a text file containing FTP commands; the
  12.                  commands will automatically run after FTP starts.
  13.   -a             Use any local interface when binding data connection.
  14.   -A             login as anonymous.
  15.   -w:buffersize  Overrides the default transfer buffer size of 4096.
  16.   host           Specifies the host name or IP address of the remote
  17.                  host to connect to.

  18. Notes:
  19.   - mget and mput commands take y/n/q for yes/no/quit.
  20.   - Use Control-C to abort commands.
复制代码
用 ftp -s:filename 命令。

论坛徽章:
0
5 [报告]
发表于 2010-09-03 11:37 |只看该作者
回复 4# longbow0


    我的意思是怎么在perl 中实现:
use Net::FTP;
$ftp =Net::FTP->new($host,Timeout=>30) or die "could not connect\n";
$ftp->login($username,$password) or die "could not login\n";
$ftp->binary;
$ftp->cwd ('/') or die "cannot change directory";

这是使用了Net::FTP模块,现在直接用ftp命令,怎么调用

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
6 [报告]
发表于 2010-09-03 11:48 |只看该作者
还是 Net::FTP 吧。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP