I can't run shell script

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
oligalma
Level 3
Level 3
Posts: 104
Joined: Tue Jan 31, 2017 5:13 am

I can't run shell script

Post by oligalma »

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).
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
xenopeek
Level 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: I can't run shell script

Post by xenopeek »

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
User avatar
oligalma
Level 3
Level 3
Posts: 104
Joined: Tue Jan 31, 2017 5:13 am

Re: I can't run shell script

Post by oligalma »

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 25
Level 25
Posts: 29597
Joined: Wed Jul 06, 2011 3:58 am

Re: I can't run shell script

Post by xenopeek »

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
User avatar
oligalma
Level 3
Level 3
Posts: 104
Joined: Tue Jan 31, 2017 5:13 am

Re: I can't run shell script

Post by oligalma »

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.
Locked

Return to “Scripts & Bash”