Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

running scripts on debian

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
m_p_w
Posts: 9
Joined: 2016-09-11 20:38

running scripts on debian

#1 Post by m_p_w »

Ok, I am a little bit confused, normally it says that you should not add extension (like .sh) to the script, but I have noticed that, the system does not execute the script with no extension.
Why this happens?
Why do people use Visual Studio? It not logical to use VS because It is not capable with wine! Additionally, I failed my VC++ programming exam because I couldn't find the "compile" button in VS. If you know where it is please contact me.

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: running scripts on debian

#2 Post by dasein »

Some DEs define an association between the .sh file extension and the shell, much in the same way that they define an association, for example, between the .jpg extension and an image viewer. But that association is merely a convention and is by no means required. For any arbitrary file foo, you can run it as a shell script using

Code: Select all

sh foo
You can also identify a file as a script (as well as specifying an alternate interpreter) internally. Google shebang linux for more information.

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: running scripts on debian

#3 Post by debiman »

with "the system" do you perchance mean a file manager?

m_p_w
Posts: 9
Joined: 2016-09-11 20:38

Re: running scripts on debian

#4 Post by m_p_w »

debiman wrote:with "the system" do you perchance mean a file manager?
not really, because I created a file.desktop which is supposed to execute my script (very basic one -> #!/bin/bash and a command)
When I try to run the script then it doesn't work, but if I create a script with the .sh extension then it works.

resources (to make sure that you know what I am doing):
-http://www.cyberciti.biz/faq/howto-run- ... -in-linux/ ----> creating and running script
-http://askubuntu.com/questions/503127/s ... -extension -----> why I think script.sh is bad practice
Why do people use Visual Studio? It not logical to use VS because It is not capable with wine! Additionally, I failed my VC++ programming exam because I couldn't find the "compile" button in VS. If you know where it is please contact me.

User avatar
bw123
Posts: 4015
Joined: 2011-05-09 06:02
Has thanked: 1 time
Been thanked: 28 times

Re: running scripts on debian

#5 Post by bw123 »

I created a file.desktop which is supposed to execute my script (very basic one -> #!/bin/bash and a command) When I try to run the script then it doesn't work, but if I create a script with the .sh extension then it works.
That doesn't sound right, I do name all my homade scripts with .sh extension just for clarity, and keep them in ~/bin

Scripts with any extension(no ext) will run on the Exec= line in a .desktop file, but you may need to put the complete path.
resigned by AI ChatGPT

pendrachken
Posts: 1394
Joined: 2007-03-04 21:10
Location: U.S.A. - WI.

Re: running scripts on debian

#6 Post by pendrachken »

m_p_w wrote:
debiman wrote:with "the system" do you perchance mean a file manager?
not really, because I created a file.desktop which is supposed to execute my script (very basic one -> #!/bin/bash and a command)
When I try to run the script then it doesn't work, but if I create a script with the .sh extension then it works.

resources (to make sure that you know what I am doing):
-http://www.cyberciti.biz/faq/howto-run- ... -in-linux/ ----> creating and running script
-http://askubuntu.com/questions/503127/s ... -extension -----> why I think script.sh is bad practice

One: make sure you have

Code: Select all

 
Exec = /path/to/my/script
Two: make sure you are not MixIng CaSe in your path.

three: make sure your .desktop isn't calling "myscript.sh" instead of "myscript" if if you don't use the extension.

four: There is nothing wrong with having the extension. In many cases, I use the .sh extension to differentiate scripts from binaries, especially if the scripts are usually executed from the system PATH.

Five: I didn't read through the second link, but it is from an Ubuntu user, and while there are some that are decent I'm sure, those USERS are not known to be the most technically savvy. Take what they say with a dump truck load full of salt...

six: this goes back to point four, in UNIX / Linux binaries don't REQUIRE an extension due to the "magic number", there also isn't anything preventing file extensions. In many cases extensions can be quite useful to differentiate between files.


EDIT: just read through the second link. Was a stupid as I thought. The poster was quoting Googles scripting guide for Google stuff ( internal stuff) and not anything else. Don't listen to him / her.
fortune -o
Your love life will be... interesting.
:twisted: How did it know?

The U.S. uses the metric system too, we have tenths, hundredths and thousandths of inches :-P

Post Reply