我之前更改了主机并且脚本可以运行,但我必须更改服务器和端口。
脚本如下:
echo "FTPing file..."
ftp -p -n -v my.server.com 8888 << EOT
user myusername mypassword
prompt
bin
put ${FILEDIR}.gz ${FILE}.gz
quit
END_SCRIPT
exit 0
我收到的错误是这样的:
Backing up KB mysql database
Starting dump to file...
Dump complete...
Gzipping file...
Gzip complete...
/home2/myuser/backups/zips/mykb.sql.2017_02_08.gz was created:
-rw-r--r-- 1 myusername myusername 126315 Feb 8 21:44 /home2/myuser/backups/zips/mykb.sql.2017_02_08.gz
FTPing file...
/home2/myuser/backups/backupkb.sh: line 46: warning: here-document at line 39 delimited by end-of-file (wanted `EOT')
ftp: connect: Connection refused
Not connected.
Interactive mode off.
Not connected.
Not connected.
我对 unix 还不太熟悉,这是一个在我共享的租用网络服务器上作为 cron 作业运行的错误,所以我真的不知道这个错误意味着什么。
谁能告诉我我做错了什么?
答案1
这“此处有文件”必须以与开头相同的符号结尾。以 开头EOT
,但以 结尾END_SCRIPT
。
这是正确的代码:
echo "FTPing file..."
ftp -p -n -v my.server.com 8888 << EOT
user myusername mypassword
prompt
bin
put ${FILEDIR}.gz ${FILE}.gz
quit
EOT
exit 0