Running .sh from main menu

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
red-e-made
Level 5
Level 5
Posts: 526
Joined: Sat Jul 14, 2007 11:31 am

Running .sh from main menu

Post by red-e-made »

I've Googled around quite a bit on this, so just to let you know beforehand: chmod +x /file.sh changes nothing, nor does "sh /file.sh" nor "bash /file.sh"

With that out of the way ...

I'm trying to put a new item on my menu, the executable of which is an .sh file. The files works perfectly well if I navigate to it and click it - it asks if I want to run or display it - but when I add the .sh to the menu, nothing happens.

Stranger still, when I run "sh /file.sh" in the terminal, this works perfectly well. The same command in the menu does nothing.

Thoughts?
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
shane
Level 5
Level 5
Posts: 940
Joined: Sun Feb 25, 2007 11:15 pm
Contact:

Re: Running .sh from main menu

Post by shane »

At the beginning of your script your should have

Code: Select all

#!/bin/bash
And then instead of

Code: Select all

sh /path/to/script.sh
just have

Code: Select all

/path/to/script.sh
This might solve it...

P.S. Is this script supposed to run in a terminal? Then it would be different...
red-e-made
Level 5
Level 5
Posts: 526
Joined: Sat Jul 14, 2007 11:31 am

Re: Running .sh from main menu

Post by red-e-made »

shane wrote:At the beginning of your script your should have

Code: Select all

#!/bin/bash
And then instead of

Code: Select all

sh /path/to/script.sh
just have

Code: Select all

/path/to/script.sh
This might solve it...

P.S. Is this script supposed to run in a terminal? Then it would be different...
Strangely, the beginning of the script is actually "#!/bin/sh"
User avatar
shane
Level 5
Level 5
Posts: 940
Joined: Sun Feb 25, 2007 11:15 pm
Contact:

Re: Running .sh from main menu

Post by shane »

I'm not sure how much of a difference it makes... There are some tiny differences between sh and bash. In Mint the default shell is bash which is why my scripts start like that. Did you try running the script directly in the menu without 'sh'? That first line defines what kind of script it is and it should run automatically... just like when you double click.
emorrp1

Re: Running .sh from main menu

Post by emorrp1 »

my /bin/sh is currently symlinked to /bin/dash (no idea why), but I think it might be to /bin/bash on a fresh install. In other words, if that is the case, it makes absolutely zero difference which line goes at the top of file
red-e-made
Level 5
Level 5
Posts: 526
Joined: Sat Jul 14, 2007 11:31 am

Re: Running .sh from main menu

Post by red-e-made »

shane wrote:I'm not sure how much of a difference it makes... There are some tiny differences between sh and bash. In Mint the default shell is bash which is why my scripts start like that. Did you try running the script directly in the menu without 'sh'? That first line defines what kind of script it is and it should run automatically... just like when you double click.
Running it directly - using just the directory path - yields nothing.

I'm stumped, personally.
Locked

Return to “Software & Applications”