Shell script to open a URL

后端 未结 6 1065
既然无缘
既然无缘 2021-02-01 13:51

How do I write a simple shell script (say script.sh), so that I can pass a URL as an argument while executing?

I want a browser to start with the page opened on that URL

6条回答
  •  一个人的身影
    2021-02-01 14:53

    For Windows,

    You can just write start filename_or_URL

    start https://www.google.com
    

    It will open the URL in a default browser. If you want to specify the browser you can write:

    start chrome https://www.google.com
    start firefox https://www.google.com
    start iexplore https://www.google.com
    

    Note: The browser name above can be obtained from the exe file found in program files (sample: C:\Program Files\Internet Explorer\iexplore.exe) if you wish to open multiple URLs.

    start chrome "www.google.com" "www.bing.com"
    

    It was tested with .sh (shellscript file) and .bat files.

提交回复
热议问题