Reputation: 2697
I have two commands in that I need to run on CMD.I want to make a bash file so that I can run commands in one click.And I want to wait some time for executing 1st one completely
sudo docker run -d --link selenium-hub:hub selenium/node-chrome
sudo docker run -d --link selenium-hub:hub selenium/node-firefox
Upvotes: 0
Views: 1219
Reputation: 64
You can do this with "&&"
you could put this in a "script.bat":
sudo docker run -d --link selenium-hub:hub selenium/node-chrome && sudo docker run -d --link selenium-hub:hub selenium/node-firefox
And if you want to wait between the commands, use something like this:
sudo docker run -d --link selenium-hub:hub selenium/node-chrome && sleep 1000 && sudo docker run -d --link selenium-hub:hub selenium/node-firefox
You can chain this indefinetely. For example you could do sudo apt update && sudo apt upgrade && sudo apt autoremove
As stated in another answer, &&
this will check if the previous command was successful. If you don't want any validation you have to use ;
for BASH or &
for CMD
Upvotes: 2
Reputation: 9133
create a file with .sh and put the content as :
#!/bin/bash
sudo docker run -d --link selenium-hub:hub selenium/node-chrome
sudo docker run -d --link selenium-hub:hub selenium/node-firefox
In windows just Logical AND will work:
sudo docker run -d --link selenium-hub:hub selenium/node-chrome && sudo docker run -d --link selenium-hub:hub selenium/node-firefox
Refer this LINK:
Command A && Command B
Execute Command A, evaluate the errorlevel after running and if the exit code (errorlevel) is 0, only then execute Command B
Command A & Command B
Execute Command A, then execute Command B (no evaluation of anything)
Upvotes: 0