在windows的cmd执行winscp命令,使用winscp的脚本对remote linux系统进行某些操作。
参考https://qiita.com/mima_ita/items/35261ec39c3c587210d8
- 执行过程中,如果有命令报错也会继续执行。
- 在windows cmd使用set可以设置变量,在winscp脚本文件(scp-script1.txt)读取并使用
# //scp-script1.txt
# two ways to pass variable,one is to use set before execute winscp script
# another is to pass variable in winscp script
# if want to use variable a after defining it,use %a%
# cannot use set a=1,b=2 ,else a will be defined as (1,b=2)
#set lpath1=C:\***
#set rpath1=/***
#winscp.com /script=C:\**\scp-script1.txt /parameter yourusername yourpwd /log=C:\***\log.txt
# connect
open %1%:%2%@192.168.**.**
#rpath1=/***
cd %rpath1%
#lpath1=C:\***
lcd %lpath1%
#ls
#lls
#to move local files to remote server , must add /(linux File separator ) after remote path
#if file exist in destination path ,it will be replaced
put *.txt %rpath1%/
#also can use this ,put files to cuurent remote pwd,now it is %rpath1%
#put *.txt
#downlaod file to local from remote server
#if file exist in destination path ,it will be replaced
#to move local files to remote server , must add \(windows File separator ) after remote path
get 1.log %lpath1%\
#downlaod file to local from remote server amd rename it
get 1.log %lpath1%\2.log
echo %1%
echo %rpath1%/
#modify file authority
chmod 777 1.sh
#sh ./1.sh
call ./1.sh
close
exit