LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-13-2019, 01:28 AM   #1
Drosera_capensis
Member
 
Registered: Jun 2018
Posts: 153

Rep: Reputation: Disabled
Basic question on bash scripts


Hello everyone.

Ubuntu BionicBeaver 18.04 on my side.

When double-clicking on a bash script in the Nautilus graphical interface, a window appear (see picture attached).

However, executing the bash script on the shell with this command is working and the program is opening.
Quote:
sh file
Why is it the case? Why is it not possible to execute a bash script just double-clicking at it?

Thanks for your help, cheers.
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2019-04-13 07-17-05.png
Views:	29
Size:	70.8 KB
ID:	30335  

Last edited by Drosera_capensis; 04-13-2019 at 01:30 AM.
 
Old 04-13-2019, 07:19 AM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,627

Rep: Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695Reputation: 2695
This may have more to do with Nautilus than with shell scripting.
Disclaimer: I am not currently using Nautilus, and therefore cannot easily test behavior.


I would research Nautilus behavior first. Also try to right click on your script icon and examine what nautilus THINKS it has as properties. This may be instructive.

That said:
First: make sure that your shell script is written so that it does not depend upon the PATH or other environmental variables. You cannot be certain that the environment it runs with under a GUI is the same as that in your normal terminal session.

Second: write your script so that it does something to log that it ran, or that a window opens for it to display that you have time to SEE it.
You need to be SURE what is happening, and evidence to support your ideas about what is going on. A bit of logging may help.

Third: permissions on the script should be such that it is executable. Do not depend upon Nautilus to be able to read your mind and add sh or bash to the desktop link magically, it must run when called by name alone. (Or full path and name.)

Last edited by wpeckham; 04-13-2019 at 07:28 AM.
 
Old 04-13-2019, 08:38 AM   #3
Drosera_capensis
Member
 
Registered: Jun 2018
Posts: 153

Original Poster
Rep: Reputation: Disabled
Hello wpeckham, thanks for your answer.

It seems that I was using Nautilus as you quote in the first line of your answer.

Testing another software called Nemo (!) provides the option of running bash scripts directly as I*was intending to do.

Nevertheless, I*have noted your subsequent advises and will keep them in mind for further inquiries.

Cheers!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Python Scripts as a Replacement for Bash Utility Scripts LXer Syndicated Linux News 1 01-17-2013 08:08 AM
Where are BASH commands stored? Not scripts but what bash exe uses. theKbStockpiler Programming 11 02-23-2011 03:06 PM
KDE 4 Autostart Program Bash Script to Write Autostart Bash Scripts for You! jdmcdaniel3 SUSE / openSUSE 1 05-03-2010 06:17 AM
[SOLVED] Finding bugs in bash scripts, Analyis tool for bash traene Programming 2 10-31-2009 11:42 AM
Basic GUI (non-x) needed to run bash scripts AP81 Programming 8 02-09-2007 09:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration