1

I have this simple command saved as .sh-file

xdg-open https://stackoverflow.com

upon opening it, I can choose between launching it directly or in a terminal. However, it only works when opening it directly. When I chose "Run in Terminal", it shows a Terminal, which instantly closes again and nothing happens.

Why does this behave differently and how do fix it, since I later need user input in the script from the terminal?

1 Answer 1

0

You should add the 'shebang' to the first line of your script.:

#!/bin/bash
xdg-open https://stackoverflow.com

This tells how the script is executed or which interpreter should be run to execute your code.

Then you need the execute permission for it. You can set it in the properties in your GUI or commandline

chmod +x myscript.sh

After this you should be able to execute it and your default browser should open a new window.

1
  • unfortunately I tried both of these already, and it still doesn't work...
    – xeruf
    Commented Feb 13, 2018 at 19:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .