How to ftp multiple files using shell script

I am trying to transfer multiple files from one machine to another using a 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 that it hangs between them, but when I try to execute each command on the command line. after execution, mput *.txtit asks for confirmation for each file when I enter yes, then moves on to the next file and asks again.

Am I missing something?

Thank.

+5
source share
4 answers

I tried something like this

prompt
mput *.txt
Team

prompt closed user interaction, and then it worked correctly.

+4
source

From the manual:

-i .

+3

Based on the code snippet, it should look like this:

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

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

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

+2
source
ftp -n ftp.test.com <<+
user ftpUser  password 
cd  local_dir/
lcd  remote_dir/
mget *.*
mdelete *.*
quit
bye
+
0
source

All Articles