You are not logged in.

#1 2009-09-25 17:41:08

Greenstuff
Member
From: Israel
Registered: 2009-06-30
Posts: 64

How do I make the shell indentify my program?

Hi,
I wrote a simple command line phone book. I'd like it to work so when I type into the shell "phone Jerry Johnshon" I get Jerry's number for example. I wrote the program in Python as a python script that takes the name as an arguement. However right now I have to set up a bash alias to /path/to/script/phone.py so I can call the "phone" alias. I'd like to do that in a more elegent way, simular to how Mplayer can be invoked by typing Mplayey [file]. I was wondering how can I achive that effect?

Offline

#2 2009-09-25 17:59:22

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: How do I make the shell indentify my program?

put this in your ~/.bash_profile:

PATH=/path/to/script:${PATH}

This won't take (automatically) effect take effect until you log off and back on. If you want to test it before that, just type this in a terminal:

source ~/.bash_profile

EDIT:
Oh, and name your file /path/to/script/phone (without the .py extension), chmod u+x it and put this at the top of your script:

#!/usr/bin/env python

Last edited by klixon (2009-09-25 18:02:36)


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#3 2009-09-25 21:46:48

tlvb
Member
From: Sweden
Registered: 2008-10-06
Posts: 297
Website

Re: How do I make the shell indentify my program?

You could also move it to a place that is in your $PATH. Note that the directories in that list is often only writable by root.


I need a sorted list of all random numbers, so that I can retrieve a suitable one later with a binary search instead of having to iterate through the generation process every time.

Offline

Board footer

Powered by FluxBB