1

I am writing a shell script to auto-deploy a program with Jboss-cli, in linux ubuntu. I need to open the jboss cli interface and execute some commands but I want to do this automatically. what it looks like

cd /opt/jboss/bin
./jboss-cli.sh --connect

the above line open the jboss command line. I would like to be able to send a command to the open program like: undeploy FlcErp.ear

I've tried to echo it and give it straight text but nothing will execute until the Jboss program is done running.

I've also tried ./jboss-cli.sh --connect undeploy "FlcErp.ear" but It reads "FlcErp.ear" as a command

Sam Orozco
  • 113
  • 5

1 Answers1

5

If jboss-cli.sh reads from standard input, you can pipe the command to it:

echo 'undeploy FlcErp.ear' | ./jboss-cli.sh --connect

To execute multiple commands, you can use multiple echo commands.

{ echo 'undeploy FlcErp.ear'; echo 'other gommands'; echo 'go here'; } | ./jboss-cli.sh --connect

but a here-doc is usually easier:

./jboss-cli.sh --connect <<EOF
undeploy FlcErp.ear
other commands
go here
EOF
Barmar
  • 9,648
  • 1
  • 19
  • 28