dpgf42422 2015-11-30 18:57
浏览 101


I have a web app written in Go and deployed on Heroku. Recently, I've implemented a new feature that needs to run a bash script file and retrieve its output. The command I'm using is:

out, err := exec.Command("bash", script_path, arg).Output()

Where script_path is the absolute path to the script. (which is built dynamically by using the caller filepath) And arg is an input to the script.

This command works fine in my local machine but not in Heroku:

18:51:40 http: panic serving exit status 127

ps: If I run the same command on "heroku run bash", it works.

Any thoughts?

  • 写回答

1条回答 默认 最新

  • ds3422222 2015-11-30 19:20

    a shell return code of 127 is to designate "Command not found".

    You can see this behavior with this small example.

    $ nonesuch
    -bash: nonesuch: command not found
    $ echo $?

    This sort of issue usually means you need to add


    to the PATH env var. i.e.

     export PATH="$PATH:/full/path/to/myscriptdir withSpaces" 

    There are several places this can be accomplished, but it depends on your organizations rules for such things.

    To immediately resolve the problem, add to the $HOME/.profile file of the userID that runs Heroku OR there is likely a Heroku specific config file that it could be added to. (I don't have experience w Heroku).

    It's interesting that this article Heroku config files doesn't mention PATH variable.

    As you have discovered, you can edit your code to include the full path directly, i.e.

    out, err := exec.Command("/bin/bash", path.Join(".", "src", "ext", "dextenso.sh"), 


    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 工业数据采集技术+存储架构推荐
  • ¥15 GPT-SOVITS如何训练少数民族语言支持合成语音
  • ¥20 树莓派4b使用Camera Module 3时出现the system should be configured for the legacy camera stack问题
  • ¥200 GitHub开源程序配置在VScode调试
  • ¥15 爬虫保存的scv文件0kb
  • ¥20 如何实现基于强化学习的带电作业机械臂的运动规划与控制
  • ¥15 使用wpf制作打砖块游戏时遇到的一个Bug
  • ¥15 qrCodeDetector.detectAndDecode
  • ¥15 海洋可控源和大地电磁一维联合反演
  • ¥15 MFC多文档程序获取视图指针问题