Redian新闻
>
what's wrong with this ftp batch file?
avatar
what's wrong with this ftp batch file?# Unix - 噫吁兮,危乎高哉
j*r
1
I just wrote a batch file to download files by ftp like this:
ftp -n 128.104.1.1
user yang yangpwd
ascii
verbose
cd data
get aaa.zip
close
bye
But after being connected, it stopped before verifying username
and password. Can anyone tell me what's wrong?
Thanks a lot,
avatar
w*n
2
the ftp program always tries to get username and password from tty,
instead of stdin which can be redirected. the solutions are:
1) put username and password in $HOME/.netrc file, or
2) use expect

【在 j*******r 的大作中提到】
: I just wrote a batch file to download files by ftp like this:
: ftp -n 128.104.1.1
: user yang yangpwd
: ascii
: verbose
: cd data
: get aaa.zip
: close
: bye
: But after being connected, it stopped before verifying username

avatar
s*d
3
of course it won't work since ftp is an interactive process.
use expect to do this job.

【在 j*******r 的大作中提到】
: I just wrote a batch file to download files by ftp like this:
: ftp -n 128.104.1.1
: user yang yangpwd
: ascii
: verbose
: cd data
: get aaa.zip
: close
: bye
: But after being connected, it stopped before verifying username

avatar
j*r
4
Here is my .netrc ( username: yang pwd:yangpwd)
"machine 128.10.1.5 login yang password yangpwd"
The problem is when I run ftp 128.10.1.5, it said
Error - .netrc file not correct mode.
Remove password or correct mode.
Can any daxia tell me how to fix this?
Thanks.

【在 w*****n 的大作中提到】
: the ftp program always tries to get username and password from tty,
: instead of stdin which can be redirected. the solutions are:
: 1) put username and password in $HOME/.netrc file, or
: 2) use expect

avatar
w*n
5
make .netrc only readable and writable by yourself.
chmod 600 .netrc

【在 j*******r 的大作中提到】
: Here is my .netrc ( username: yang pwd:yangpwd)
: "machine 128.10.1.5 login yang password yangpwd"
: The problem is when I run ftp 128.10.1.5, it said
: Error - .netrc file not correct mode.
: Remove password or correct mode.
: Can any daxia tell me how to fix this?
: Thanks.

avatar
c*o
6
try:
ftp -n > /dev/null <open 128.104.1.1
user yang yangpwd
bin
cd data
get aaa.zip
bye
EOF

【在 j*******r 的大作中提到】
: I just wrote a batch file to download files by ftp like this:
: ftp -n 128.104.1.1
: user yang yangpwd
: ascii
: verbose
: cd data
: get aaa.zip
: close
: bye
: But after being connected, it stopped before verifying username

avatar
j*r
7
多谢各位大侠指点,终于搞定了。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。