免费注册 查看新帖 |

Chinaunix

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

请教关于脚本中传变量的FTP自动登录问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-06 11:01 |只看该作者 |倒序浏览
自己写了个FTP自动传输的脚本,内容精简如下:

case $1 in
aa)
hostip="192.0.0.10"
;;
bb)
hostip="192.0.0.11"
;;
*)
echo "Unknown host"
exit
;;
esac

login="user $1"  #have to input password
#login="user $1 password" #needn't to input password

ftp -i -n <<END
open $hostip
$login
cd tmp
mget file*
bye
END



这个脚本在4台机子上运行过,其中SCO(2台), Linux, AIX上。不管是login变量带不带password,结果都如下:
1. SCO, FTP server (Version wu-2.6.1(1) Mon Feb 26 23:48:24 PST 2001),正常;
2.Linux, vsFTPd 2.0.1,正常;
3.AIX, FTP server (Version 4.2 Tue Nov 14 12:49:19 CST 2006),正常;
4.SCO, FTP server (Version 2.1WU(1)),失败。而当把ftp命令里的“$login”换成“user username password”(确切的用户名和密码)时,又能正常。

请教一下,这个问题,是FTP server的问题?还是我这个脚本本身有什么问题?
由于安全方面考虑,我不想把密码用明文方式写在脚本里面,有什么办法可能解决以上问题么?
或是有别的什么方法来实现脚本ftp传输。
谢谢。

论坛徽章:
0
2 [报告]
发表于 2010-01-06 11:32 |只看该作者
provide your shell with -x option for debuging to see if $login is expanded correctly. ( e.g. #!/usr/bin/sh -x )

For the intention of not using password in plain text, there is no ways but converting your entire script to an executable binary file by using certain encoding/encryption utility ... You can search for the related information about how to on  this site

论坛徽章:
0
3 [报告]
发表于 2010-01-06 11:54 |只看该作者
原帖由 nhw_cs 于 2010-1-6 11:32 发表
provide your shell with -x option for debuging to see if $login is expanded correctly. ( e.g. #!/usr/bin/sh -x )

For the intention of not using password in plain text, there is no ways but con ...


谢谢。
我之前有echo $login的内容,是正确的。
我刚才又试了好几次,又都是全部正常的。
我现在只能相信是FTP密码太复杂,输入有误了,或是键盘不好使。不然实在找不到其实合逻辑的解释。

谢谢你的回复。
p.s. 本想用英文回复,奈何水平刚够读懂,写不来,呵呵。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP