user1431282
user1431282

Reputation: 6835

Running a Python Script Like a Built-in Shell Command

I have gone through the following steps.

  1. Made the file executable,
  2. Tested that the file could be run with ./script1.py,
  3. Added the file's directory to the system $PATH.

However, at this point, am I supposed to be able to say script1 arg1 and be able to run it like a built-in bash command or do I still need to set up an alias.

My quick hack is to set up an alias; however, I am not sure if this is redundant.

alias script1 = $HOME/dir/script1.py

Upvotes: 0

Views: 167

Answers (1)

Elazar
Elazar

Reputation: 21585

mv script1.py script1

should do the trick. I won't recommend it though.

A better way is to add a symblic link:

ln -s script1.py script1

This way, you can add the link directly in some system path - probably /usr/bin - and won't need to change $PATH at all:

sudo ln -s script1.py /usr/bin/script1

Make sure it will not override any existing file.

Upvotes: 1

Related Questions