Let's say I have a downloadable text file on my website that says
sudo apt-getupdate
How can I make it so that the user downloads it and it auto puts that code into terminal? What would I do for something that has many lines of code?
Let's say I have a downloadable text file on my website that says
sudo apt-getupdate
How can I make it so that the user downloads it and it auto puts that code into terminal? What would I do for something that has many lines of code?
If you put this line:
at the beginning of the text file, Ubuntu will know than is an executable file to be interpreted by bash. So your file would look something like this:
When the user double clicks the file, she/he will be asked if wants the executable to be run in a terminal.
You can simply give your user these commands:
You will need to replace
bash
with the program which should execute your script.The first method will not save the file on disk. It will only be downloaded and directly executed. If the file should be saved, you can use the following:
The file will be kept as
script.sh
in the current directory. This requires a shebang line at the top of the file.