Given the following script
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd /home/dbadmin/backup
mput *.gz
quit
END_SCRIPT
the mput *.gz
from a directory /backups
that contains *.gz files, results in this error:
mput t1.gz? mput t2.gz? ./temp.sh: line 14: /home/dbadmin: is a directory
I am not sure how to change the script without put
ting individual file names. I want to mput
all files in this directory.
By putting an exit 0 after END_SCRIPT, the error disappeared, and I am interested in why this happened.
What about to replace mput to generated put
?
ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd /home/dbadmin/backup
$(find *.gz -maxdepth 0 -type f -printf 'put %p\n')
quit
END_SCRIPT
How it works:
When HERE-IS-DOCUMENT will be resolved, find *.gz ...
will generate multiple lines for each file found by mask *.gz
:
put 1.gz
put 2.gz
...
and your script content that will be executed by ftp
will be like that:
quote USER your_user_name
quote PASS your_passwd
cd /home/dbadmin/backup
put 1.gz
put 2.gz
...
quit
Regarding /home/dbadmin: Is a directory
I belive you have single line /home/dbadmin
in your script (or something like $SOME_COMMAND /home/dbadmin
).