• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Problem getting bash script to execute

 
Rancher
Posts: 5035
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just recently got a bare computer, installed Ubuntu 22 and am trying to tailor it for my usage.  I have no experience with linux.
I have installed wine to run a Windows program.
I have a .sh file:

in a folder on the desktop.
When I right click on the .sh file and select: Open With bash I can not see anything happen.
If I select: Run as a program a terminal window is opened and the script is executed.

What do I need to do to have the script execute when opening with bash?
Thanks,
 
Sheriff
Posts: 4644
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the script file have executable permissions?

I don't know if it will cause any problems, but I wouldn't add a .sh to a file which you want to run using the bash shell.  To me, .sh means use the Bourne shell.
 
Norm Radder
Rancher
Posts: 5035
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Does the script file have executable permissions?


Yes.  The Run as a program choice doesn't appear without the executable permission.

To me, .sh means use the Bourne shell


I appear to have bash.  The script executes when I use Run as a program but not with Open With bash.

What changes should I make to have the script file open with the default double click?

 
Norm Radder
Rancher
Posts: 5035
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone use script files to tailor their linux system?  Am I trying to do something unusual?
On Windows, I use batch files, shortcuts and registry entries to create a workable environment.
 
Ron McLeod
Sheriff
Posts: 4644
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which desktop manager are you using -- GDM, KDE, ???
 
Norm Radder
Rancher
Posts: 5035
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this what you are asking about:  GNOME Display Manager
 
Ron McLeod
Sheriff
Posts: 4644
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a computer using GDM (Gnome).  I tried this and I was able to launch the application by double-clicking on the desktop icon:

~/Desktop/xterm.desktop
~/.local/share/start-xterm

I'm not recommending running as root - it was the only user configured on the computer which I had available
 
Norm Radder
Rancher
Posts: 5035
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I don't know anything about linux.
Is this a file:   xterm.desktop that is on the desktop?
How was that file created?
I assume the script file being executed does not have an extension.  I see that its first line has: /usr/bin/bash vs  /bin/bash in my script file???

For one test I used the file manager to create a link to a .sh file and copied that link file to another location.  The link can cause the script to execute with the right selections from the presented menu.

I also created another .sh file that I asked the original question about.
I have two file managers:  nautilus and nemo.  Clicking on the .sh file when using nemo prompts if I want to run or display or ...

I would like to execute the .sh file and not have to answer questions.  Is that possible?
 
Ron McLeod
Sheriff
Posts: 4644
582
VSCode Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Norm Radder wrote:Is this a file:   xterm.desktop that is on the desktop?

Yes - both are files.  ~ represents your home directory, so for you, the files should probably be put in the /home/normt/Desktop directory (may be different with Ubuntu).

The desktop file is used to provide specifications to launch your application from the desktop.  Some information here: https://linuxconfig.org/how-to-create-desktop-shortcut-launcher-on-ubuntu-22-04-jammy-jellyfish-linux

Norm Radder wrote:How was that file created?

I used the vim editor, but any editor could be used.

Norm Radder wrote:I assume the script file being executed does not have an extension.

Script files don't need an extension, the fist line, with the #!(shebang) specifies the shell/interpreter to use.

Norm Radder wrote:I see that its first line has: /usr/bin/bash vs  /bin/bash in my script file???

I am running Oracle 8, and the bash shell is located in the /usr/bin directory.  Ubuntu may be different.

Norm Radder wrote:I have two file managers:  nautilus and nemo ...

The computer I am using uses Nautilus (the default for Gnome).

Norm Radder wrote:I would like to execute the .sh file and not have to answer questions.  Is that possible?

Yes, but I don't really have enough knowledge/experience to help much more - sorry.  I rarely use a graphical desktop, and I typically use Redhat/Oracle/Centos Linux (I do use Ubuntu OS inside containers, but those are never graphical).  Hopefully someone else that uses Ubuntu and Gnome as their everyday platform can help.




 
Norm Radder
Rancher
Posts: 5035
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all that.  I guess there are many versions of Linux with their own way of doing things.

I got a working shortcut on the desktop using the details in the link you provided.
Thanks again,

Now onto the next part of learning to use my new Ubuntu system:  Migrate Android projects under Eclipse to Android Studio with gradle.  
The Initial import of the eclipse project without any gradle files into AS has failed miserably with lots of cryptic error messages about missing parts.
 
Put a gun against his head, pulled my trigger, now he's dead, that tiny ad sure bled
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic