writting executable script
October 8th, 2006 mysurface Posted in Bash, chmod, Developer, file, python, sh, which | Hits: 107890 | 22 Comments »
Shell script (sh), Bash script (bash), Python and perl are all scripting language. By default, to run a scripting file, for example Python script, you need to do this:
python myscript.py
Another example for shell script:
sh myscript.sh
But we make is executable and can execute by running directly like this
./myscript.py
If you place your script into directory that exported into your PATH, such as /usr/bin; you can run without specified ./
How to make your script executable that?
- Add the path of script interpreter at the first line of your script.
- Change mode to executable
Let say I want to make my python script executable, I add this entry at the first line of myscript.py:
#!/usr/bin/python
Then i change mode to executable:
chmod +x myscript.py
For shell script, add this entry:
#!/bin/sh
You can use “which” to check the real path of the interpreter, like this
which sh
Another advantage of adding “sha bang” (#!….) is the script will be recognize by file.
file myscript.sh
If you do not add “sha bang”, file will display
myscript.sh: ASCII text
But after you add that,
myscript.sh: Bourne shell script text executable
October 8th, 2006 at 6:58 pm
We may use the
env
instead if we don’t know the exact location ofpython
:#! /usr/bin/env python
More at:
python FAQ, python’s mailling list discussion
September 17th, 2009 at 6:39 am
how can I write an executable script using the linux that computes summary statistics for the variables x1,x2,and x3. Include: n, no. of missing observations, mean, variance, standard deviation, and minimum and maximum values.
September 17th, 2009 at 6:41 am
how to compute correlattions among three variables?
December 28th, 2010 at 11:11 pm
Interesting read i think your website is fantastic with top notch content which i like to add to my bookmarks. I’d like to share everyone this new type of app that allows you to spy on other peoples iphone pretty clever if you ask me check out cell phone spy
March 16th, 2012 at 1:56 pm
writting executable script » Linux by Examples I was recommended this website by my cousin. I’m not sure whether this post is written by him as nobody else know such detailed about my difficulty. You are amazing! Thanks! your article about writting executable script » Linux by ExamplesBest Regards Lisa
June 3rd, 2012 at 5:55 am
How come you do not have your site viewable in wap format? Can not view anything in my Droid.
June 23rd, 2012 at 2:47 am
There is obviously a bunch to know about this. I believe you made certain nice points in features also.
January 11th, 2014 at 9:08 pm
Heya i am for the first time here. I found this board and I
find It truly useful & it helped me out a lot. I hope to give something back and aid others like you
aided me.
best rated casinos in southern california [Laurinda]
June 10th, 2014 at 2:59 am
Hi i am kavin, its my first occasion to commenting anyplace, when i read this piece of writing
i thought i could also create comment due to this good
paragraph.
December 24th, 2015 at 6:21 pm
If I could come across some more posts like this one, that would be great.
January 3rd, 2016 at 4:10 pm
I believe I actually checked out a different post similar to this one in the past. It had the exact same content and is equally well published.
January 15th, 2016 at 4:25 am
Great write-up. It looks like much time and energy went towards this one.
January 18th, 2016 at 3:23 am
It is evident that this blog post is one of the best I’ve found today. It’s also evident the person who’s page this is put a whole lot of work in it. Great job!
February 22nd, 2016 at 6:33 pm
This unique page is very interesting. I may definately be coming back to your site.
March 24th, 2016 at 3:32 am
It is evident that the following blog post is probably the best I have found today. It’s also evident the person who’s page this is put much work in it. Great work!
March 30th, 2016 at 12:29 am
You can hardly find posts like this anymore. I recall when you could find one or two posts like this in minutes but now it’s much harder.
April 11th, 2016 at 8:50 pm
This content is very engaging. I will certainly be returning your website.
April 21st, 2016 at 6:42 am
This page is very interesting. I may certainly be returning your website.
April 27th, 2016 at 9:26 pm
Very good content when compared to some of the similar posts I’ve checked out. Carry on the nice work.
May 6th, 2016 at 12:03 pm
It is always just so exciting to discover good information such as this considering the irrelevant content that’s out there. I mean, you can definitely tell that much time and patience with into this. Do you work with content writers or do you compose your own content?
May 10th, 2016 at 7:01 pm
This is easily some of the best information I’ve stumbled on today. It’s not necessarily what I was looking for nonetheless it certainly got my attention. I’m glad I took the time to look it over.
August 18th, 2016 at 12:27 am
Great looking website. Presume you did a bunch of your ownyour very own html coding
nhl 17 http://www.gta-five-forum.com/blog-e31345-fifa-points-To-Lose-Weight.html