winscp自动化 脚本文件

在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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值