ftp_upload() { echo "upload $2 to remote server..." up_file_name=$(basename $2) remote_dir="/opt/repos/gxdb/ci_node/result_TPCH" > ./ftp_up_tar.sh echo "ftp -i -n << EOF" >> ./ftp_up_tar.sh echo "open 192.168.8.77" >> ./ftp_up_tar.sh echo "user yz yz" >> ./ftp_up_tar.sh echo "binary" >> ./ftp_up_tar.sh echo "cd \$1" >> ./ftp_up_tar.sh echo "lcd \$2" >> ./ftp_up_tar.sh echo "put \$3" >> ./ftp_up_tar.sh echo "exit 0" >> ./ftp_up_tar.sh echo "EOF" >> ./ftp_up_tar.sh sh -x ./ftp_up_tar.sh "${remote_dir}" "$1" "${up_file_name}" echo "Upload end." } ftp_upload "/opt/remote_dir/" "./test/myfile.txt"