日期:2014-05-17  浏览次数:20865 次

window系统里传递命令到liunx服务器并执行
我的目的就是 在window系统里传递命令到liunx服务器并执行 
我试了在命令行调用(putty.exe)putty -pw 123456 -m F:\test.sh  root@10.50.130.55 方法这种命令但是 好像不行 liunx命令行弹出来一下就自动关闭啦

请求各位大神 指点一二
  

------解决方案--------------------
pink指令
------解决方案--------------------
PuTTY的命令行工具叫做plink
------解决方案--------------------
是的 我少了l 是plink.下面是实际使用中的powershell脚本。
$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 "任务已经完成,按任意键结束。"

------解决方案--------------------
引用:
大神 有没有简单点的列子啊


test.bat
PLINK.EXE -ssh -v -pw MyPassword MyAccount@MyIP -m MyScript.sh > MyLog.txt