我正在尝试使用ftp
脚本,该脚本在同一连接中的不同文件夹中发送文件,但下面的脚本没有运气。
#!/bin/bash
HOST_NAME=host.server
username= user_name
passwd= password
remote = /path_to_remote/folder
local = /path_to_local/folder
folder=$1
pwd
ftp -in <<EOF
open $HOST_NAME
user $username $passwd
cd local/
lcd remote/
put a_filename_<timestamp>.txt
mkdir $remote/$folder
cd $remote/$folder
lcd $local/$folder
put b_filename.txt
close
bye
除此之外,在运行时,是否可以只发送过去10分钟内创建的最新文件?
答案 0 :(得分:0)
试试这个:
#!/bin/bash
HOST_NAME=host.server
username=user_name
passwd=password
remote=/path_to_remote/folder
local=/path_to_local/folder
folder="$1"
pwd
ftp -in <<EOF
open "$HOST_NAME"
user "$username" "$passwd"
cd local/
lcd remote/
put a_filename_<timestamp>.txt
mkdir "$remote/$folder"
cd "$remote/$folder"
lcd "$local/$folder"
put b_filename.txt
close
bye
EOF
注意:
shell不允许=
旁边的空格。
引用变量。
OP代码缺少结束EOF
。
我单独留下<timestamp>
,这是一个不同的问题。