Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339
Rep:
Shell Scripting
Well I know this has been asked before but I can't find it and this pice of info seems to evade me:
What is the extention (or whatever you Linux people call it) that is years for the equivalent of win's batch file.
I can take it from there.
AFAIK UNIX/Linux doesn't use file extensions to figure out how the program should be run. But if you're asking about Bash script you can use .sh file extension.
Or you can append "#! /bin/bash"(without quotes) to your script.
Last edited by konsolelover; 10-25-2011 at 01:12 AM.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
Quote:
Originally Posted by konsolelover
Or you can append "#! /bin/bash"(without quotes) to your script.
You have to put that as first line. So you have to prepend your script.
It (just) indicates that when the file permissions include executable, the shell
knows what application should be used to run the script.
Indeed, the suffix usually is .sh if you want to use a file suffix.
Both actions do not make a file executable. You'd need to set the exec bit for that.
You have to put that as first line. So you have to prepend your script.
It (just) indicates that when the file permissions include executable, the shell
knows what application should be used to run the script.
Indeed, the suffix usually is .sh if you want to use a file suffix.
Both actions do not make a file executable. You'd need to set the exec bit for that.
Code:
chmod ugo+x <filename>
to make it executable for everyone.
If it is not executable, run it with
Code:
sh /path/to/your/script
jlinkels
Yes , you are right. Actually using append instead of prepend was a typo. He didn't ask about how to run the script that's why i didn't bother to write about chmod(which i should have done).;p
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
I think the OP meant something like "on lightyears distance". Which is as matter of speech of course. I assume M$ products have not propagated thru the galaxy yet.
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339
Original Poster
Rep:
Ok one by one. If there are no extensions how does it know what to do with the file? (I heard that in the rely days of NT they put letters befor the thing) As for thé hilighted part of thé quote I'm typing with an iPod with autocorrect on and that sometimes switches to an international keyboard... I can't remember what I wanted to say but it might of been "Used". And is win's creator really copyrighted enough that you can't even say the initials. If you live in America (which you probably do) You have a freedom of speech man, end hipiness. Same with Linix's father... Why arnt we alley to say the whole thing? Well moving on. Why does this have to be so difficult? Does Linux still support the .elf too?
Ok one by one. If there are no extensions how does it know what to do with the file? (I heard that in the rely days of NT they put letters befor the thing)
It knows by the permissions on the file. Make it executable, and it'll be treated as a program...whether it DOES anything or not, depends on the contents.
Quote:
As for thé hilighted part of thé quote I'm typing with an iPod with autocorrect on and that sometimes switches to an international keyboard... I can't remember what I wanted to say but it might of been "Used". And is win's creator really copyrighted enough that you can't even say the initials. If you live in America (which you probably do) You have a freedom of speech man, end hipiness. Same with Linix's father... Why arnt we alley to say the whole thing? Well moving on. Why does this have to be so difficult? Does Linux still support the .elf too?
What's difficult about it?? If the file permissions say it's executable, it runs. If not, it doesn't...actually MUCH simpler than Windows, which is dependent on the extension. Rename a .exe file to .txt, and see if you can run it on Windows.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
Quote:
Originally Posted by Zssfssz
Ok one by one. If there are no extensions how does it know what to do with the file?
There are two files on shell level: binaries and script files.
If it isn't a binary, shell looks are the first line of the script for a shebang (shebang = #!). The shebang indicates an executable which has to be used to execute the script. That is how the shell knows which application to use for the file.
Then there is also the exec bit which has to be set in order to make the shell execute that file, either a binary or a script.
If the file is not executable you still can execute it by executing a shell with the command to execute that file.
Most desktop managers or file managers have a database where you can make file associations, like associate .JPG with Gimp. But this is not a shell or linux issue. It is on top of that.
Windows OTOH doesn't know execute bits. If a file ends with .BAT it is a script, .COM and .EXE are executables. Note the non-separation of extensions from executable bit.
Then the Windows desktop manager (which is the OS itself) has a database for associations so it knows to start regedit in the background when a trojan is hidden in your mail message. Note again here the non-separation of the desktop from the OS.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.