mystryl
V2EX  ›  问与答

Alfred 中用/bin/bash/运行脚本 command not found

  •  
  •   mystryl · Aug 18, 2016 · 6234 views
    This topic created in 3730 days ago, the information mentioned may be changed or developed.

    借用了 V 友的一个 hexo 脚本,快速 cl g d 的。 但是只有将命令在 terminal 运行的时候才正常,无论是 bash 还是 zsh 运行,在 debug 里都报错

    /bin/bash: line 3: hexo: command not found

    试试看 where 吧? /bin/bash: line 3: where: command not found

    囧 where 都找不到。。 但这两条命令在 terminal 里运行都是正常的。 求问怎么了。。

    hexodir=(${HOME}/Dropbox/hexo)
    cd ${hexodir}
    hexo clean
    
    hexodir=(${HOME}/Dropbox/hexo) 
    cd ${hexodir}
    hexo generate
    
    hexodir=(${HOME}/Dropbox/hexo)
    
    cd ${hexodir}
    hexo deploy
    

    就如上三个脚本

    Supplement 1  ·  Aug 19, 2016
    感谢 ‪@Orz_C ‬ terminal 里面 echo $PATH ,然后在你的脚本第一行加上 PATH=刚才的输出
    成功了。
    10 replies  •  2020-06-22 18:23:24 +08:00
    lumen
    lumen
    Aug 18, 2016
    1
    大概是 PATH 变量里的路径没有包含命令所在路径
    UnisandK
    UnisandK
    Aug 18, 2016
    2
    LS+1 ,要不直接写绝对路径
    arphone
    arphone
    Aug 18, 2016
    3
    既然已经 cd ${hexodir} 了,应该 ./hexo xxxx 就可以了
    mystryl
    mystryl
    OP
    Aug 18, 2016
    4
    @arphone [2016-08-18 15:03:07][ERROR: action.script] /bin/bash: line 2: ./hexo: No such file or directory

    感觉这不对啊。。
    mystryl
    mystryl
    OP
    Aug 18, 2016
    5
    @lumen 请问如何添加?捣鼓了一个 echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile 好像无效


    @UnisandK 直接调用 /usr/local/bin/hexo ?
    '''
    hexodir=(${HOME}/Dropbox/hexo)
    cd ${hexodir}
    /usr/local/bin/hexo clean
    '''
    [2016-08-18 15:29:56][ERROR: action.script] env: node: No such file or directory
    UnisandK
    UnisandK
    Aug 18, 2016
    6
    @mystryl 还要其他环境变量那没法了。。你加个 source ~/.bash_profile 试试
    arphone
    arphone
    Aug 18, 2016
    7
    @mystryl sorry,看错了,应该是 cd 到 hexo 所在目录,然后 ./hexo ;或者就是把 hexo 可执行文件路径加到 path 环境变量里去
    mystryl
    mystryl
    OP
    Aug 19, 2016
    8
    感谢 ‪@Orz_C ‬ terminal 里面 echo $PATH ,然后在你的脚本第一行加上 PATH=刚才的输出
    成功了。
    zhanglintc
    zhanglintc
    Aug 19, 2016
    9
    你在 terminal 里能用, 那是 PATH 里有比如 hexo 这个二进制文件的路径. 但是你在使用 alfred 的时候并没有这个路径. 所以你要写绝对地址.

    我认为是这样的.
    lkai
    lkai
    Jun 22, 2020
    10
    @mystryl 加了好像不行呢~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1504 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 22:39 · PVG 06:39 · LAX 14:39 · JFK 17:39
    ♥ Do have faith in what you're doing.