【问题标题】:Executing / Running a python script from ubuntu server从 ubuntu 服务器执行/运行 python 脚本
【发布时间】:2010-04-08 16:32:12
【问题描述】:

谁能帮助我如何通过命令行运行 python 脚本?

我的python脚本http://buffis.com/2007/07/25/getting-info_hash-for-xbt-tracker/comment-page-1/

我正在使用这个命令/var/www/hash_info.py /var/www/Muha_Album.7912.torrent

我已经复制了上面文章链接中提到的依赖文件bencode.py。当我执行上述命令时,我收到错误 No such file or directory 但是当我将文件 chmod 到 644 时,它说 Permission denied 该文件存在于该位置。

我已经使用这个命令apt-get install python-gtk2 python-glade2安装了pythong

【问题讨论】:

    标签: python linux bash


    【解决方案1】:
    python /var/www/hash_info.py /var/www/Muha_Album.7912.torrent
    

    【讨论】:

      【解决方案2】:

      也许它说:

      bad interpreter: No such file or directory
      

      然后,第一行,所谓的shebang line 就是这里的问题。我想您需要将其更改为真正安装 python 的位置。在我的 Ubuntu 安装中,它是 /usr/bin/python

      此外,来自 voyager 的解决方案也应该适合您。

      【讨论】:

      • 要从当前目录运行脚本,在添加 shebang 行后,请确保在脚本名称前加上点斜杠,表示您要在当前目录中运行文件,而不是系统中的一些可执行文件:./hash_info.py
      【解决方案3】:

      试试chmod 744

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-09-01
        • 1970-01-01
        • 2023-02-07
        • 2016-06-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多