LinuxQuestions.org
Help answer threads with 0 replies.
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 10-25-2011, 12:43 AM   #1
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Rep: Reputation: Disabled
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.
 
Old 10-25-2011, 12:46 AM   #2
hen770
Member
 
Registered: Oct 2010
Distribution: Arch
Posts: 136

Rep: Reputation: 7
.bat
 
0 members found this post helpful.
Old 10-25-2011, 12:54 AM   #3
konsolelover
Member
 
Registered: Jul 2011
Location: 127.0.0.1
Distribution: Arch, Ubuntu 11.04
Posts: 78

Rep: Reputation: 3
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.
 
Old 10-25-2011, 01:57 AM   #4
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by konsolelover View Post
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.
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
 
1 members found this post helpful.
Old 10-25-2011, 02:12 AM   #5
konsolelover
Member
 
Registered: Jul 2011
Location: 127.0.0.1
Distribution: Arch, Ubuntu 11.04
Posts: 78

Rep: Reputation: 3
Quote:
Originally Posted by jlinkels View Post
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
 
Old 10-25-2011, 02:19 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
Quote:
What is the extension that is years for the equivalent of win's batch file.
Well I am even further in the dark than everyone else What does the highlighted part even mean??? What do years have to do with a batch file?
 
2 members found this post helpful.
Old 10-25-2011, 06:09 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
"years" sounds a bit like "used" ...
 
Old 10-25-2011, 07:56 AM   #8
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
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.

jlinkels
 
Old 10-25-2011, 10:00 AM   #9
Zssfssz
Member
 
Registered: Sep 2011
Location: Las Vegas!
Distribution: Ubuntu n' Flavors, ReactOS, MINIX3, FreeDOS, Arch
Posts: 339

Original Poster
Rep: Reputation: Disabled
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?
 
Old 10-25-2011, 10:37 AM   #10
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
You may need to narrow down what sort of file you are talking about as a search for 'elf file extension' yielded 5.2 mil results and the first was:
Quote:
Details for file extension: ELF - Wii Executable File (Nintendo)
So my answer to that would be no.

By the way ... M$ is not because it is taboo but considered more like swearing in these parts so not nice to say out loud
 
Old 10-25-2011, 10:49 AM   #11
linuxwin2
Member
 
Registered: Oct 2011
Posts: 44

Rep: Reputation: Disabled
For example write a script hello.sh and put
Code:
#!/bin/bash
echo "Hello World"
Code:
$chmod +x hello.sh
$./hello.sh
 
Old 10-25-2011, 10:52 AM   #12
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,636

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by Zssfssz View Post
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.
 
Old 10-25-2011, 10:59 AM   #13
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by Zssfssz View Post
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.

jlinkels
 
Old 10-31-2011, 12:45 AM   #14
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Quote:
Originally Posted by grail View Post
You may need to narrow down what sort of file you are talking about as a search for 'elf file extension' yielded 5.2 mil results and the first was:

So my answer to that would be no.
I don't think that was what the OP meant. See, for example:
http://en.wikipedia.org/wiki/Executa...inkable_Format

Or look at the output if you run `file' on any binaries on your system.

So, I'd say the answer (if I really did understand the question) is probably yes.

Cheers,

Evo2.
 
  


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: Terminal functions for shell scripting with Shell Curses LXer Syndicated Linux News 0 03-26-2008 11:50 PM
SHELL scripting/ shell functions mayaabboud Linux - Newbie 6 12-26-2007 08:18 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM

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

All times are GMT -5. The time now is 05:35 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