window系统里传递命令到liunx服务器并执行
我的目的就是 在window系统里传递命令到liunx服务器并执行
我试了在命令行调用(putty.exe)putty -pw 123456 -m F:\test.sh root@10.50.130.55 方法这种命令但是 好像不行 liunx命令行弹出来一下就自动关闭啦
pink指令
PuTTY的命令行工具叫做plink
$Host.UI.RawUI.WindowTitle="同步脚本" function ScriptBlock{param($hostname,$username,$password,$command) Set-Location "C:\Users\Administrator\Desktop\PuTTY" #设置plink工作路径 $comandstr="cmd.exe /c plink.exe $username`@$hostname -pw $password $command" $msg=invoke-expression $comandstr -ea SilentlyContinue return $hostname,$msg } $a = new-object -comobject wscript.shell $intAnswer = $a.popup('选择"是"全部同步,选择"否"只同步launcher,选择"取消"将终止同步', 0,"文件选择",3+32) If ($intAnswer -eq 6) { $select="all" } elseif ($intAnswer -eq 7){ $select="launcher"}else{ exit } $c=Get-Credential root $hostname="192.168.88.124" $username=$c.GetNetworkCredential().username $password=$c.GetNetworkCredential().password $command="/root/appshell/xget-source.sh $select" Write-Host "正在执行获取操作,请等待……" ScriptBlock $hostname $username $password $command $command="/root/appshell/xpush-file.sh $select" Write-Host "正在执行推送操作,请等待……" ScriptBlock $hostname $username $password $command Read-Host "任务已经完成,按任意键结束。"