Psexec仅通过Jenkins显示第一行

时间:2016-06-22 17:12:09

标签: batch-file jenkins cmd psexec

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

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

示例命令:

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.

1 个答案:

答案 0 :(得分:0)

我对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

也许对某人有用。