unix - Execute a python script as a command -
i'm writing python script placed in location. want execute command. ex.
$ find_branch test
where find_branch script placed in anywhere in system.
i know how achieve this. can run on place script present chmod u+x on script , removing .py script
sudo nano /usr/bin/testpyscript
then inside script:
#!/usr/bin/python print("i'm python script")
give x
permission:
sudo chmod +x /usr/bin/testpyscript
now can use regular command:
bash-4.2$ testpyscript i'm python script
it doesn't have @ /usr/bin
, location inside $path do. let's want located @ folder inside home directory, this:
pwd /home/brunorb mkdir somedir sudo mv /usr/bin/testpyscript somedir/ export path=$path:/home/brunorb/somedir/ testpyscript # folder in system i'm python script
Comments
Post a Comment