不要接受价值观 [英] Jar not accepting values

查看:219
本文介绍了不要接受价值观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 jar 文件,当从命令提示符运行时运行良好,我的意思是它要求用户输入,但是当从 psexec 或 powershell jenkins 不接受值并开始处理更多命令。
简而言之:当执行jar时,有一个菜单可供选择。如果选择在特定范围内,则效果很好,否则会给出消息输入的值无效。在这里,我将循环收到消息。任何人都可以建议我出错或需要对设置进行任何更改。

I have a jar file which when run from command prompt works well, I mean it asks for user input,but when the same is run from psexec or powershell or jenkins doesn't accept values and starts processing further commands. In short: When jar is executed, there is a menu to make choices. If choice is within specific range, it works well else gives message entered value is not valid. Here I am getting the message in a loop. Can anyone suggest where I am going wrong or need to make any change in the settings.

PS〜我正在尝试在远程机器上执行命令而我正在调用jar使用 java -jar myFile.jar

P.S.~ I am trying to execute commands on remote machine and I am calling the jar using java -jar myFile.jar

推荐答案


<你能给我一个基本的想法,我怎么能在詹金斯实现它。

can you give a basic idea how I can achieve it in Jenkins.

所以


  • 如果你的jar接受通过参数化构建在jenkins工作中传递它们的参数

  • 如果没有,而是提示你,你是在问题:你需要一种自动化控制台的方法。

这个工作的X平台工具是期望。关于它的坏处是它在Windows上需要大量的代码(如果你在Linux上运行它可能已经存在)。作为替代方案,您可以使用Autohotkey,但它无法轻松检测控制台文本(与预期读取控制台缓冲区不同)。但是,如果提示以确定的方式出现(即刚刚开始),您可以执行以下操作:

X-platform tool for the job is Expect. Bad thing about it is that it requires a lot of deps on Windows (if you are running this on Linux expect is probably already there). As alternative you could use Autohotkey altho it can't detect easily console text (unlike expect which reads console buffer). However if prompt appears in deterministic manner (i.e. just after start) you could do something like:

java -jar myfile.jar
sleep 5
autohotkey.exe SendKeys.ahk

SendKeys.ahk将是简单如下:

SendKeys.ahk would be as simple as:

 WinActivate <pid / window name ...>
 Send answer1<ENTER>answer2<ENTER> ....

但它可以更加强大,以便密钥发送不依赖于控制台窗口状态。

but it could be made more robust so that key sending will not depend on console window state.

在cmd中,您可以使用 title 命令设置一些特定的窗口名称,然后您可以使用AHK激活该标题。

In cmd you can set some specific window name with title command then you can activate that title with AHK.

这篇关于不要接受价值观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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