创建程序的符号链接

发布于 2024-10-04 14:28:19 字数 554 浏览 0 评论 0原文

假设我在 ~/programming/ass1 中,可执行文件在 ~/programming/ass1/seattle/seattle_repy/repy.py 中。

我尝试创建一个像这样的符号链接

ln -s seattle/seattle_repy/repy.py repy

能够键入,

python repy restrictions.test example.1.1.repy

,以便

python seattle/seattle_repy/repy.py restrictions.test example.1.1.repy

但它不起作用(我得到“python:无法打开文件'/home/philipp/Desktop/Uni/NTM/UE/Uebungsblatt 3/safe_check .py':[Errno 2]没有这样的文件或目录”)。 所以repy.py找不到safe_check.py。

这有可能吗?

干杯, 菲利普

Suppose I am in ~/programming/ass1 and the executable is in ~/programming/ass1/seattle/seattle_repy/repy.py.

I tried to create a symlink like so

ln -s seattle/seattle_repy/repy.py repy

to be able to type

python repy restrictions.test example.1.1.repy

instead of

python seattle/seattle_repy/repy.py restrictions.test example.1.1.repy

But it didn't work (I get "python: can't open file '/home/philipp/Desktop/Uni/NTM/UE/Uebungsblatt 3/safe_check.py': [Errno 2] No such file or directory").
So repy.py can't find safe_check.py.

Is this possible at all?

Cheers,
Philipp

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧人 2024-10-11 14:28:19

您需要 frob sys.path 来添加包含模块的路径,但制作一个调用 exec python ~/programming/ass1/seattle/seattle_repy/ 的 shell 脚本可能更容易复制.py。

You'll need to frob sys.path to add the path containing the modules, but it's probably easier to make a shell script that calls exec python ~/programming/ass1/seattle/seattle_repy/repy.py.

雨的味道风的声音 2024-10-11 14:28:19

感谢伊格纳西奥和马克的建议。
我用 ~/programming/ass1 中的以下 bash 脚本解决了这个问题

#!/bin/bash
exec python ~/programming/ass1/seattle/seattle_repy/repy.py $@

为了最终得到我想要的东西,我将其复制到 /usr/bin 并创建了一个符号链接:

sudo cp repy.sh /usr/bin/
sudo ln -s /usr/bin/repy.sh /usr/bin/repy

所以现在我只能说 repy requests.test 示例。 2.1.repy 就可以了。

Thanks for the tips Ignacio and Mark.
I solved it with the following bash script in ~/programming/ass1

#!/bin/bash
exec python ~/programming/ass1/seattle/seattle_repy/repy.py $@

To finally get what I want I copied it to /usr/bin and created a symlink to it:

sudo cp repy.sh /usr/bin/
sudo ln -s /usr/bin/repy.sh /usr/bin/repy

So now I can just sayrepy restrictions.test example.2.1.repy and it'll work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文