PUTTY/PLINK 如何确定命令已返回? [英] How does PUTTY/PLINK determine a command has returned?

查看:101
本文介绍了PUTTY/PLINK 如何确定命令已返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是换行符吗?迅速的?究竟是什么?

Is it newline? prompt? What exactly?

尝试在 plink 上运行 powershell 并且命令执行但 plink 无法识别其完成并且会话挂起.最奇怪的是,该命令在通过 shell(通过 Putty)发送时成功执行.但是,通过 plink 发送时,相同的命令挂起...

Trying to run powershell over plink and the command executes but plink doesn't recognise its finished and the session hangs. Most curiously though, the command executes successfully when sent through the shell (via Putty). However, when sent via plink, the same command hangs...

有什么想法吗?

推荐答案

好吧,我仍然不太确定问题是什么,但我已经通过 TeamCity 论坛找到了解决方法.

Ok, well I'm still not quite sure what the problem is, but I've found a workaround via the TeamCity forums.

基本上,您希望将输出的一些任意字符串和管道回显到您的 powershell 可执行文件中,如下所示:

Basically you want to echo some abitrary string and pipe that output into your powershell executable, like thus:

echo 'executing powershell...' | C:\windows\system32\windowspowershell \v1.0\powershell.exe  exit 1

那么你的完整 plink 命令就变成了:

So then your full plink command becomes:

plink.exe user@someIp -i key.ppk -P 22 -batch -v "echo 'executing powershell...' | C:\windows\system32\windowspowershell\v1.0\powershell.exe exit 1"

铌.Plink 仍会使用此方法传递返回码和控制台输出.

Nb. Plink will still pass through return codes and console output using this method.

TeamCity 论坛链接:

Link to TeamCity forum:

http://youtrack.jetbrains.net/issue/TW-6021

希望能帮到你

这篇关于PUTTY/PLINK 如何确定命令已返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆