!/bin/bash
cd /home/pi/dockertest
sudo -S <<< Adminpassword docker-compose up -d --scale chrome=2 --scale firefox=0
I want to add a script to pm2 to start the SeleniumGrid. So I have created .sh file with above code and added to pm2 with
pm2 start '/home/user/dockertest/startGrid.sh' --name SeleniumGrid
Docker & Grid is up now, but in pm2 monit console, I see the command keeps iterating over and over. How to prevent this?
-S
in sudo
allows input from pipes to be the password
so you need to remove -S
from sudo
:
#!/bin/bash
cd /home/pi/dockertest
sudo <<< 'Adminpassword docker-compose up -d --scale chrome=2 --scale firefox=0'
and if you really want it to take the password from a pipe:
#!/bin/bash
cd /home/pi/dockertest
sudo -S bash -c 'Adminpassword docker-compose up -d --scale chrome=2 --scale firefox=0'
Hope that helps