Turn python script into an installed UNIX command (Mac OS X)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Turn python script into an installed UNIX command (Mac OS X)
# 1  
Old 10-21-2010
Turn python script into an installed UNIX command (Mac OS X)

Okay so i have a script i wrote in python. I want to turn this script into an INSTALLED COMMAND to run in terminal.

Right now i run it like this in terminal...

$ python myscriptname.py
or
$ ./myscriptname.py


but i want to be able to run it like this in terminal...

$ myscriptname

is this possible?
I have basic programming knowledge and know all the basic terminal commands. I just want to create my own terminal command that i don't have to be in the same directory as the script is. Can someone tell me how?
# 2  
Old 10-21-2010
You are mostly there. Rename it without suffix and put it in a $PATH directory or its directory in $PATH. Without a suffix, if you later want to do it over in JAVA, C or C++, nobody will know.
# 3  
Old 10-21-2010
Thank you so much! Works great!

Last edited by cbreiny; 10-21-2010 at 03:56 PM..
# 4  
Old 10-21-2010
Sometimes I maintain my scripts as *.sh in my src dir, and make them by suffix by moving them to my bin with no suffix and with execute permissions, which most CM tool do not set.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Programming

Python script to grep fields and use values from file 1 as argument for another command

Hi Experts, I am working one one python script in version 3.x and 2.6. Need your support to complete it Basically for both commands i have telnet to device and run command and then receiving input File 1 and File 2 I have two commands, need to grep data and output in csv file. Next script/code... (0 Replies)
Discussion started by: as7951
0 Replies

2. Shell Programming and Scripting

How to use scl enable python command call with in bash shell script?

I have a bash shell script, within it i am using the below two commands . its failing right on scl enable command itself. if i run it by itself without a shell, it works fine. by default it is using pythin version 2.6 something. i want to use 3.4 version for that reason with in the shell... (3 Replies)
Discussion started by: cplusplus1
3 Replies

3. Shell Programming and Scripting

Pass File name and Directory Path through command to python script

I'm writing python script to get the file-names in the current directory and file sizes .I'm able to get file list and their sizes but unable to pass them through command line. I want to use this script to execute on other directory and pass directory path with file name through command line. Any... (1 Reply)
Discussion started by: etldeveloper
1 Replies

4. Solaris

Command to turn off or GUI

What command turns GUI off and on in Solaris 10 (4 Replies)
Discussion started by: zbest1966
4 Replies

5. OS X (Apple)

Can I erase and start my mac with unix command

I made a tragic error and erased the extensions manager from my IMac. Now, I can't get the computer to boot up. It just stays on the gray screen. I've tried using the open apple+s method, which brings up the command console (not sure if I've got the lingo down right), and I've tried everything, but... (12 Replies)
Discussion started by: ccff22290
12 Replies

6. Shell Programming and Scripting

Script to check if SQLLDR has been installed on Unix/Aix servers

How can i check if sqlldr has been installed on my AIX/UNIX mechine? Is there any unix script to check this one out.... (0 Replies)
Discussion started by: msrahman
0 Replies

7. UNIX for Dummies Questions & Answers

problem with python on mac

Hi, I'm sure there's a very easy way to fix this but i'm a newbie so I'm posting this. The problem is that whenever I run python on the terminal I can no longer use the left and right arrows to move left or right, or the up/down arrows to call commands used before. Whenever I click an arrow I get... (0 Replies)
Discussion started by: thefloydpink
0 Replies
Login or Register to Ask a Question