how to ftp multiple file using shell script

2019-04-28 18:25发布

I am trying to ftp multiple files from one machine to another using shell script. Below is my script :-

ftp -nv <<EOF
open home.machine.com
user remote monday
binary
mput *.txt
bye
<<EOF

now, the problem is, it hangs in between, but when i try each and every command on the command prompt. after i execute mput *.txt it asks for confirmation for each and every file, when i enter yes then it moves on to next file, and asks again.

Am i missing something?

Thanks.

标签: unix ftp
4条回答
我命由我不由天
2楼-- · 2019-04-28 19:20

From the manual:

-i Turns off interactive prompting during multiple file transfers.

查看更多
▲ chillily
3楼-- · 2019-04-28 19:21

i tried something like this

prompt
mput *.txt

prompt command closed the user interaction, and then it workedd properly.

查看更多
SAY GOODBYE
4楼-- · 2019-04-28 19:21
ftp -n ftp.test.com <<+
user ftpUser  password 
cd  local_dir/
lcd  remote_dir/
mget *.*
mdelete *.*
quit
bye
+
查看更多
放荡不羁爱自由
5楼-- · 2019-04-28 19:22

Based on your code snippet, it should be like this:

ftp -inv <<EOF
open home.machine.com
user remote monday
binary
mput *.txt
bye
<<EOF

notice the inclusion of '-i' in the ftp arguments.

also, it is not advisable to use mput since it will be difficult to track errors than transferring files individually

查看更多
登录 后发表回答