1

I want to write a Linux shell script that would run the client.sh program to open a JBoss Fuse shell and then in turn run the commands like "container-stop" in the JBoss Fuse shell and eventually exit from the JBoss Fuse shell. What is the best way to accomplish this?

Regards.

dave
  • 91
  • 6
  • Possible duplicate of [What is the cleanest way to ssh and run multiple commands in Bash?](https://stackoverflow.com/questions/4412238/what-is-the-cleanest-way-to-ssh-and-run-multiple-commands-in-bash) – Alessandro Da Rugna Jul 21 '17 at 07:14
  • 1
    this question is much like a duplicate, because `client.sh` basically sets up an SSH connection to the running instance. Just use plain ssh client from shell and send whatever command you like. – Alessandro Da Rugna Jul 21 '17 at 07:16

1 Answers1

1

The command that you need to execute is the following:

./client -r 3 -d 2 -u admin -p admin 'container-stop my-container'

this example will authenticate and will execute the desired command a single step. The parameters -u and -p are for username and password. There are few optional parameters like -r for retries in case of error and -d for delay. You can omit them.

If you have few commands to execute like restarting a single Fabric environment than probably is OK to write it as a bash script.

But if you need to be flexible, centralized, to be able to run on many environments at once, universal, portable, etc, then my opinion is that you better use some automation system. It will pay off later. In that case I can suggest you to look at Ansible because it's lightweight and it's easy to write the script for it. This is an application that you install on a single machine. From there you can SSH into remote machines and execute specific tasks. Those instructions you have to provide in a simple Ansible script called playbook. You can have multiple target hosts also and you can execute as many tasks as you want even simultaneously.

Angelo A
  • 108
  • 1
  • 4