How do I install a script to run anywhere from the

2019-01-21 17:11发布

If I have a basic Python script, with it's hashbang and what-not in place, so that from the terminal on Linux I can run

/path/to/file/MyScript [args]

without executing through the interpreter or any file extensions, and it will execute the program.

So would I install this script so that I can type simply

MyScript [args]

anywhere in the system and it will run? Can this be implemented for all users on the system, or must it be redone for each one? Do I simply place the script in a specific directory, or are other things necessary?

8条回答
贼婆χ
2楼-- · 2019-01-21 18:06

Just create symbolic link to your script in /usr/local/bin/:

sudo ln -s /path/to/your/script.py /usr/local/bin/script
查看更多
该账号已被封号
3楼-- · 2019-01-21 18:07

The best place to put things like this is /usr/local/bin.

This is the normal place to put custom installed binaries, and should be early in your PATH.

Simply copy the script there (probably using sudo), and it should work for any user.

查看更多
登录 后发表回答