13

We are trying to read the JBoss status using the jboss-cli.bat command.

jboss-cli.bat -c --command=":read-attribute(name=server-state)" > "$env:JBOSS_HOME\JbossServerStatus.txt"

Storing the status in the TXT file. Since "Press any key to continue" occurs, the controller doesn't return back.

Is there any way to ignore the Press any key to continue without editing the jboss-cli.bat? We know that by adding set NOPAUSE = true, will avoid this problem, but we are looking for solution without editing the file.

TT.
  • 15,774
  • 6
  • 47
  • 88
Chandru M
  • 133
  • 1
  • 7
  • You don't need to change the batch file, just define the variable before calling the batch file. `set "NOPAUSE=true" & jsboss-cli.bat .... ` – MC ND Apr 11 '17 at 12:16
  • @MCND It is not working. Here's my code set NOPAUSE="true" jboss-cli.bat -c --command=":read-attribute(name=server-state)" Am running this as .PS1 file – Chandru M Apr 11 '17 at 13:06
  • Try: `< nul jboss-cli.bat ....` – Aacini Apr 11 '17 at 14:16

1 Answers1

20

The jboss-cli.bat includes a line as

 if "x%NOPAUSE%" == "x" pause

so, we only need to declare a environment variable called NOPAUSE and set it to some value before calling the jboss-cli.bat

set "NOPAUSE=true"
jboss-cli.bat .....

If the joss-cli.bat is being called from a powershell script (from comments), then we will need to use something like

$env:NOPAUSE = "true"
.\jboss-cli.bat .....
MC ND
  • 69,615
  • 8
  • 84
  • 126