【问题标题】:Can execute binary, but not using "source"可以执行二进制,但不能使用“源”
【发布时间】:2013-11-11 21:17:05
【问题描述】:

试图让watch jobs 工作。这很棘手,因为jobs 报告当前shell 拥有的作业,而watch 创建另一个shell。因此我想运行. watch jobssource watch jobs,但我得到了这个错误:

-bash: source: /usr/bin/watch: cannot execute binary file

这是file /usr/bin/watch的输出:

/usr/bin/watch: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, BuildID[sha1]=0xe207fd209faf781a58f5f30922c99da759bd3953, stripped

这种情况下如何调试source

【问题讨论】:

    标签: bash shell jobs watch


    【解决方案1】:

    您只能source 脚本,而不是可执行文件。试试:

    while true; do clear; jobs; sleep 2; done
    

    【讨论】:

      【解决方案2】:

      您不能在 shell 中的二进制文件中获取源,它仅适用于 shell 脚本。

      source command仅用于在当前进程中执行shell脚本,不派生新的子shell进程。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-07-25
        • 2017-01-06
        • 1970-01-01
        相关资源
        最近更新 更多