Psexec 仅通过 Jenkins 显示第一行

问题描述 投票:0回答:2

我正在尝试通过 Jenkins 使用 psexec 运行远程命令。如果我直接通过命令行运行该命令,我会得到预期的输出。如果我通过 Jenkins 运行完全相同的命令,它似乎只输出第一行。

如何让 Jenkins / PSExec / CMD 显示完整的 stdout 输出?我尝试了多个命令行标志,例如以交互模式运行 PSExec(-i、-i 0、-i 1),以及其他似乎相关的选项,甚至是那些不相关的选项。

示例命令:

PsExec.exe -accepteula \\server cmd /c ipconfig

命令提示符输出:

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com



Windows IP Configuration


Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe30::f175:1634:asf4:756e%12
   IPv4 Address. . . . . . . . . . . : 10.128.51.66
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 10.128.51.1

Tunnel adapter isatap.{5EA7E8FB-C491-483E-B24D-3CBDFA2D5619}:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Tunnel adapter Local Area Connection* 11:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
cmd exited on tst-hrm-app03.nexjtest.local with error code 0.

詹金斯输出:

C:\NexJ\jboss-5.1.0.GA\server\all_8280\jenkins\workspace\Build and Deploy TEST>PsExec.exe -accepteula \\server ipconfig

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com


Windows IP Configuration

Connecting to tst-hrm-app03.nexjtest.local...


Starting PSEXESVC service on tst-hrm-app03.nexjtest.local...


Connecting with PsExec service on tst-hrm-app03.nexjtest.local...


Starting ipconfig on tst-hrm-app03.nexjtest.local...



ipconfig exited on tst-hrm-app03.nexjtest.local with error code 0.
batch-file jenkins cmd psexec
2个回答
2
投票

我对 psexec 也有同样的问题。 Psexec 将任务列表写入文本文件。 当我尝试阅读之后。但 psexec 只读取部分行。 我通过命令组合解决了我的问题。

  1. 写入文件

    psexec \\remote_pc cmd /c tasklist /v /fi "imagename eq magentproc.exe" /fo list > C:\temp.txt

  2. 使用带有正则表达式参数的 findstr 来读取它

    psexec \\remote_pc cmd /c findstr /r ".*" C:\temp.txt

也许这对某人有用。


0
投票

我也有同样的问题。我尝试重定向到文件,它肯定有效,但是

psexec \\remote_pc cmd /c dir ^| findstr /r ".*"
也会截断输出,我想避免写入任何文件,有什么建议吗?

© www.soinside.com 2019 - 2024. All rights reserved.