osx或windows系统下,用ftp上传文件到阿里云虚拟主机脚本

某天突然发现,一直在用的ftp工具并不好用,操作界面太过繁琐,而且不太稳定。于是自己找资料,整合了几句虽然简单,但是方便的代码。

mac脚本
#从本地向FTP批量上传文档 需要赋予该.shell文件权限才能成为可执行文件
#!/bin/sh
ftp -v -n 60.200.19.158<<EOF  #主机ip,不需要端口
user userName password  # 账号以及密码
binary
hash
# 服务器的目录
cd htdocs
# cd htdocs/php
# 本地的目录
lcd /Documents/myproject/dist
# lcd /Documents/myproject/php
prompt
# 上传的文件名
# mput login.php
mput output.zip
bye
#here document
EOF
echo "commit to ftp successfully"
 
windows .bat脚本
REM ftp自动上传bat脚本  REM表示注释该行
@echo off
echo open 60.200.19.158 >> temp.txt
echo user userName password>> temp.txt
echo bin >> temp.txt
echo put "E:\MYPROJECT\dist\output.zip" "htdocs/output.zip" >> temp.txt
REM echo put "E:\MYPROJECT\php\reg.php" "htdocs/php/reg.php" >> temp.txt
echo bye >> temp.txt
ftp -n -s:"temp.txt"
REM del /q D:\MyData\Administrator\Desktop\dist-UAT.zip
pause
del /q temp.txt
posted @ 2018-08-21 10:10  kzc275  阅读(341)  评论(0编辑  收藏  举报