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


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
  • @Barmar Can you expand this answer so that first example is written for multiple commands? – 71GA Jul 23 '18 at 13:06
  • 1
    @71GA Updated the answer – Barmar Jul 23 '18 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.