I can't run shell script

Forum rules
Before you post please read how to get help
oligalma
Level 1
Level 1
Posts: 49
Joined: Tue Jan 31, 2017 5:13 am

I can't run shell script

Postby oligalma » Wed Jul 19, 2017 4:03 am

I've got Linux Mint 17 KDE. I also have a shell script, myshellscript.sh, which is located in the desktop. When I right-click it and go to Actions > Run in Konsole, the Konsole opens up and I get the following error message: Warning: Could not find '/home/marc/Desktop/myshellscript.sh', starting '/bin/bash' instead. Please check your profile settings. I'm not sure what I should do to run this file in this way (I already know how to run it using bash --> sh myshellscript.sh).

User avatar
xenopeek
Level 24
Level 24
Posts: 21459
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: I can't run shell script

Postby xenopeek » Wed Jul 19, 2017 4:19 am

oligalma wrote:I already know how to run it using bash --> sh myshellscript.sh

That's not how you run a bash script. That's how you run a sh script. bash and sh scripts are similar but different.
Is the first line of your script: #!/usr/bin/env bash
If not, what is it?
Image

oligalma
Level 1
Level 1
Posts: 49
Joined: Tue Jan 31, 2017 5:13 am

Re: I can't run shell script

Postby oligalma » Wed Jul 19, 2017 5:11 am

xenopeek wrote:
oligalma wrote:I already know how to run it using bash --> sh myshellscript.sh

That's not how you run a bash script. That's how you run a sh script. bash and sh scripts are similar but different.
Is the first line of your script: #!/usr/bin/env bash
If not, what is it?


I added this line but it's still not working.

User avatar
xenopeek
Level 24
Level 24
Posts: 21459
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: I can't run shell script

Postby xenopeek » Wed Jul 19, 2017 5:49 am

Is the script contents something you can share? Right-clicking a script file and choosing to run it in Konsole just works here. The file needs to have a valid hashbang line (as indicated above) and needs to have been marked as being executable. After that is should just work. Perhaps there is an error in your script, like not using fully qualified paths to files it uses?
Image

oligalma
Level 1
Level 1
Posts: 49
Joined: Tue Jan 31, 2017 5:13 am

Re: I can't run shell script

Postby oligalma » Wed Jul 19, 2017 7:33 am

xenopeek wrote:The file needs to have a valid hashbang line (as indicated above) and needs to have been marked as being executable.


I marked the script as executable and it worked at last! Many thanks.


Return to “Scripts & Bash”