Issue multiple commands to Karaf console from bash

I need to issue multiple commands to karaf from bash. I have this shell script which works just fine, but I think I should be able to do this without having to login to the console for each command:

openhab-cli console -p habopen bundle:stop org.openhab.io.homekit 
sleep 1s
openhab-cli console -p habopen bundle:start org.openhab.io.homekit

I’ve tried this:

openhab-cli console -p habopen bundle:stop org.openhab.io.homekit && bundle:start org.openhab.io.homekit

But it seems that after the first command is issued, the console connection is closed, so the second command is passed to bash, and of course, fails.
Any ideas appreciated

1 Like

Try semicolon: command 1;command 2.

Standard karaf allows to pass script file to client.sh. Then each line is executed in same session.

nearly. Put quotes arround the command:

openhab-cli console -p habopen "command1; command2"

otherwise the second command will be executed in the local shell not in opehanb client.

It works now. Thanks all.