Skip to content

Instantly share code, notes, and snippets.

@weiofcn
Created August 22, 2018 02:02
Show Gist options
  • Save weiofcn/8f9d7ef4b2d601797d42f2f61a500144 to your computer and use it in GitHub Desktop.
Save weiofcn/8f9d7ef4b2d601797d42f2f61a500144 to your computer and use it in GitHub Desktop.
xshell自动化命令使用
Sub Main
	xsh.Screen.Send("export update_dir=/root/zhouwei/")
	xsh.Screen.Send(VbCr) 
    xsh.Screen.Send("cd /data && rm -rf `date +%Y%m%d` && cd $update_dir && rm * -rf")
    xsh.Screen.Send(VbCr) 
	xsh.Screen.Send("scp root@10.227.101.23:/root/soc_env/CloudSocEnv*.tar.gz .")
	xsh.Screen.Send(VbCr) 
	xsh.Screen.WaitForString "root@10.227.101.23's password:"
	xsh.Screen.Send("kenchow")
    xsh.Screen.Send(VbCr) 
	xsh.Session.Sleep 3000
	xsh.Screen.Send("scp root@10.227.101.23:/root/soc/CloudSOC*.tar.gz .")
	xsh.Screen.Send(VbCr) 
	xsh.Screen.WaitForString "root@10.227.101.23's password:"
	xsh.Screen.Send("kenchow")
    xsh.Screen.Send(VbCr) 
	xsh.Session.Sleep 3000
	xsh.Screen.Send("ls *.tar.gz | xargs -n1 tar xzvf")
	xsh.Screen.Send(VbCr)
    xsh.Session.Sleep 1000
	xsh.Screen.Send("cd /virus && rm -Rf */ && cd $update_dir")
    xsh.Screen.Send(VbCr)
	xsh.Screen.Send("cd `ls -d */ | tail -1` && cd update && sh update.sh")
	xsh.Screen.Send(VbCr)
    xsh.Session.Sleep 1000
	xsh.Screen.Send("cd ../.. && cd `ls -d */ | head -1` && cd update && sh update.sh")
    xsh.Screen.Send(VbCr)
	xsh.Session.Sleep 1000
	xsh.Screen.Send("cd $update_dir &&  ps -ef | grep python")
	xsh.Screen.Send(VbCr)
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment