【问题标题】:I am trying to wirte a .py file into the write_eeprom.sh. I am getting the error 'Not Found'我正在尝试将 .py 文件写入 write eeprom.sh。我收到错误“未找到”
【发布时间】:2022-12-22 03:23:22
【问题描述】:

尝试运行此代码(使用 sh write_eeprom.sh

#!/bin/bash                                                                                                                                                                                                

testdesc=$1
qr_heisys=$2

if [[ $testdesc == "-h" ]]
then
        echo "script to write data to Board EEPROM of Heisys"
        echo "eeprom is at address 0x55"
        echo "first argument is testdesc"
        echo "second argument is qr"
        echo "usage: write_eeprom.sh "write to eeprom" "$qr_heisys""
        exit 0
fi

teststep "${testdesc}"
echo "qr_heisys = "$qr_heisys
${testpath}${script}qr2eeprom.py "$qr_heisys"

if [[ $? -ne "0" ]]
then
        fail "Error writing QR Code to eeprom"
else
        printlog  "Write QR to Boardeeprom was succesfull PASS"
fi

出现以下错误:

write_eeprom.sh: 6: [[: not found

write_eeprom.sh: 16: teststep: not found
qr_heisys = 

write_eeprom.sh: 20: qr2eeprom.py: not found

write_eeprom.sh: 22: [[: not found

write_eeprom.sh: 26: printlog: not found

【问题讨论】:

  • 确定您使用的是 bash 吗?我打赌你不是。
  • 所以我正在使用“sh write_eeprom.sh”来运行代码。如果可以,您能告诉我如何确定这不是 bash 吗?
  • sh 不是 bash,它是 sh,并且没有 bash 的许多功能。
  • 哦好的!我需要将#!/bin/bash 更改为“#!/bin/sh”吗?我怎么能或如何解决这些错误?我也使用 export PATH 来给出路径

标签: bash shell ubuntu-20.04


【解决方案1】:

如果您希望脚本按照 shebang 行的指示由 bash 执行,那么请执行

chmod +x write_eeprom.sh
./write_eeprom.sh

建议:您不需要 .sh 扩展名,您可以将其重命名为 write_eeprom 并使用 https://www.shellcheck.net/ 检查您的脚本

【讨论】:

  • 谢谢你!!这奏效了! shellcheck.net 也很有用!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-11-10
  • 2019-05-30
  • 2013-05-09
  • 2020-05-31
  • 1970-01-01
  • 2022-12-02
相关资源
最近更新 更多