LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-08-2009, 12:44 PM   #1
kcg_
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Rep: Reputation: 0
Calling .py from anywhere


Hello,

I have a python script and I am wondering is it possible to call it from anywhere. Along the same lines as how "netstat" can be called from anywhere, just by typing in "netstat" into the shell.

Can anyone tell me is this possible and if so what do I need to do?


Thanks

~ Kcg
 
Old 10-08-2009, 12:47 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
it needs to be in your path. Generally locally installed tools would be placed in /usr/local/bin, or you could modify your own path to include something additional just for you, e.g. "export PATH=$PATH:~/bin" in your ~/.bash_profile file and then putting in that directory for just you.
 
Old 10-08-2009, 12:57 PM   #3
bgeddy
Senior Member
 
Registered: Sep 2006
Location: Liverpool - England
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Posts: 1,810

Rep: Reputation: 232Reputation: 232Reputation: 232
As acid_kewpie says you need to put it somewhere in your path. To make it executable on it's own (without typing python) make the script called myscript executable with "chmod +x myscript" and if the path to your python interpreter is "/usr/bin/python" add this line first to myscript:
Code:
#!/usr/bin/python
 
Old 10-08-2009, 01:07 PM   #4
kcg_
LQ Newbie
 
Registered: Oct 2009
Posts: 2

Original Poster
Rep: Reputation: 0
It works!

Thanks for the help
 
  


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
Calling all Engineers.... barton General 13 05-08-2010 03:24 PM
calling X of another machine cjagdish69 Linux - Software 1 03-06-2009 12:02 AM
Calling all hackers... Kamikazee General 3 12-20-2005 05:49 PM
odd recursion: calling "by hand" vs calling by cronscript... prx Programming 4 02-12-2005 04:59 PM
Calling functions in C++ oulevon Programming 3 01-28-2005 03:14 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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