【问题标题】:bin/sh error and mekefile error 127 but i write bin/bash in my script?bin/sh 错误和 mekefile 错误 127 但我在脚本中编写了 bin/bash?
【发布时间】:2020-10-04 22:28:06
【问题描述】:

我有这个可以工作的 bash 脚本(它打印输出),但是当我运行程序时,最后出现错误 /bin/sh not found,makefile 错误 127。我什至没有 bin/嘘,我写了 bin/bash。 analisi.sh是脚本,这是makefile的一部分,supermercato.PID是保存线程supermercato的PID的地方。

./run: 
cd src; \
(./supermercato & echo $$! > supermercato.PID) & \
cd ..; \
sleep 25s; \
kill -1 $$(cat src/supermercato.PID); \
chmod +x ./analisi.sh
./analisi.sh $$(cat src/supermercato.PID); \ 

这是脚本analisi.shtest.log是写入输出的文件

#!/bin/bash

if [ -f "test.log" ]; then
   while read line; do echo $line; done < test.log
else
   echo "$0:Errore" 1>&2
fi

这是一个错误示例(SIGHUP 是项目的一部分)。 TEST 写在我从脚本中读取的名为 test.log 的日志文件中。

Received SIGHUP
./analisi.sh $(cat src/supermercato.PID); \ 
******TEST******
/bin/sh: 1:  : not found
make: *** [Makefile:15: run] Error 127

【问题讨论】:

    标签: c bash shell makefile


    【解决方案1】:

    这一行:

    ./analisi.sh $$(cat src/supermercato.PID); \ 
    

    有一个尾随空格(!)前面的命令以分号结尾,所以 BASH 认为你正在尝试执行 两个命令:./analisi.sh 后跟一个名称由单个文字空格字符组成的命令。

    您可以在终端中重现它。在反斜杠后加一个空格并按 Enter:

    $ echo hey; \ 
    hey
    -bash:  : command not found
    $
    

    还要检查错误信息的格式:

    $ wow
    -bash: wow: command not found
    

    所以格式是:

    <BASH>: <line number>: <command_name>: not found
    

    在你的情况下,它是

    /bin/sh: 1:  : not found
    

    注意这里有两个空格:: :

    【讨论】:

      猜你喜欢
      • 2013-08-06
      • 2022-12-07
      • 1970-01-01
      • 1970-01-01
      • 2022-08-19
      • 1970-01-01
      • 2020-01-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多