0

Im trying to write a very simple script. It should to open a web-browser (www.google.com for instance), wait for 3 seconds and kill the web-browser. What happens to me is that seems that the script do not pass from this first step.

#!/bin/bash

/usr/bin/google-chrome "http://www.google.com/" echo "Hello" sleep 3 pkill chrome

Not even showing the "Hello" in the terminal. Only the web-browser opens and no more happens.

What am I missing?

Thanks in advance.

RRR CCC
  • 113
  • 3
    Your script won't proceed until the google-chrome process you started exits (this might happen immediately if there's an already running Chrome process, in which case your google-chrome command will simply ask that process to open a new tab). You need to start it in the background for the script to be able to proceed to the remaining commands. – muru Oct 06 '22 at 12:09
  • @muru is correct. I think you can achieve what you want by adding an & at the end of command to start google-chrome – PonJar Oct 06 '22 at 12:13
  • Thanks for answering guys. The command google-chrome runs and open the Chrome window, but remains there. Is like the .sh does not noticed that the Chrome has opened finally. I mean, the Chrome window opens and loads the url, but does not start the second line command. Maybe is missing any kind of return OK from the first command to follow with the echo "Hello". What do you think? – RRR CCC Oct 06 '22 at 18:59

0 Answers0