batch-file - Psexec 仅通过 Jenkins 显示第一行

标签 batch-file jenkins cmd psexec

我正在尝试通过 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.

Jenkins 输出:

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.

最佳答案

我在使用 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

也许这对某人有用。

关于batch-file - Psexec 仅通过 Jenkins 显示第一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37974432/

相关文章:

batch-file - 安装 Win-builds 项目时如何在 yypkg 中为 sherpa.exe 设置代理信息

.net - 如何使用 .Net 命令提示符强制启动和运行 .bat 文件

c# - 如何使用 C# 将参数传递给批处理文件

python - 禁用从 GUI (PyQt) 打开 cmd

python - 从 python 运行 shell 命令

用于替换字符串的 Windows 批处理脚本

jenkins - docker build 和 publish 插件使用

jenkins - 我怎么知道 Jenkins 构建状态

svn - 使用子文件夹时,使用 SVN 插件结帐将失败

php - 微型网络 - 无法让 php.exe 返回数据