-1

I created a file named echhothis.sh which contains this code:

#!/bin/sh  
echo "This is a shell script"  
ls -lah  
echo "I am done running ls"  
SOMEVAR='text stuff'  
echo "$SOMEVAR"

Then I changed it according to your instructions:

> ter@Asus:~/Desktop$ chmod +x ~/Desktop/echhothis.sh
> ter@Asus:~/Desktop$ chmod 755 ~/Desktop/echhothis.sh

...and tried to run it like a program, from the desktop and also from the terminal, but nothing happens. What did I do wrong or what have I missed?

I tried running the script by clicking on it in the desktop GUI by using the option 'Run as program', with no results at all.

When I entered sh echhothis.sh in the terminal, it did what it is supposed to do, but I want to make a script that I can activate from the GUI Desktop in order to establish a shortcut to a file system.

The code that I entered for making the shortcut works when entered at the bash prompt. The code lines in echhothis.sh work fine as well when entered at the bash prompt. I want to run that file as a shortcut, but when I try it does nothing at all. The test.sh file works when I enter "sh test.sh" from the bash prompt, and creates the ts.txt file and fills it: "#!/bin/bash ls ~/Desktop/ > ~/Desktop/ts.txt echo" but when I try to launch it from the desktop nothing happens. No error, nothing at all.


Alas! I am not getting any further. I will refrase my question hoping that that might bring some more light into my question (I fear that I am trying to do things in Ubuntu that are far above my level of understanding). As I don't get the editing right in a comment I will start a new question and close this one (if I'm able to do so)

Thanks a lot for your answers!

muru
  • 207,228
Pitor
  • 47

1 Answers1

1

Your script or bash file does not contain errors and works. All it does is printing output to standard output.

When running it with "Run as program" from the file manager, it is normal that you do not see any output: there is no terminal to display it. To see the output, modify the script to redirect its output to a file, display it in a graphical text editor or with zenity (or kdialog).

vanadium
  • 97,564