0

这是我的脚本,用于自动化我的静态博客的 git push。当我在终端中一一运行每个命令时,它就可以工作了。我是否需要添加延迟,也许它太快了。pelican 命令(静态网站生成器)需要相当长的时间(2 秒)。在此期间脚本的其余部分是否崩溃?

    #!/bin/sh
    dropbox
    cd blog
    pelican . -s /Users/Paul-Arthur/Desktop/Desktop/Dropbox/blog/pelican.conf.py -t subtle
    cd output
    git add . 
    git commit -m 'commit'
    git push 

更新:抱歉,是的,dropbox 是我的 bash_profile 中的自定义命令(这不是问题,我知道它可以工作;))。可悲的是,当我单击我的脚本时,它执行得非常快(但不起作用),所以我看不到错误。

这是 calepin 命令的输出。这些错误是正常的,我希望它能够运行。你认为这是问题所在吗?如果是这样,我该怎么办?

    familys-imac:blog Paul-Arthur$     pelican . -s /Users/Paul-Arthur/Desktop/Desktop/Dropbox/blog/pelican.conf.py -t subtle

    ERROR: Skipping ./articles/aboutme.md: impossible to find informations about 'title'
    ERROR: Skipping ./articles/static_sites.md: impossible to find informations about 'title'
    familys-imac:blog Paul
4

1 回答 1

0

这可能是由于 « cd» 命令,因为它不是命令,它是 shell 的内置命令,并且不像命令。

要调试它,请尝试pwd在脚本中的 « cd» 行之前和之后添加 « » 命令,以确保工作目录已更改。

这也可能是由于您使用的 shell,在 shebang(脚本的第一行)中,您使用的是 /bin/sh 脚本。是好的吗?当您在 shell 中执行此操作时,您可能正在使用另一种方法,例如 bash、dash、zsh 等。

要确定这一点,请在您当前的 shell 中键入:

which `echo $0`

你会得到一个类似的答案:

/bin/bash 

或类似的东西。在你的 shell 脚本中使用它:

#!/bin/bash

再试一次你的脚本。

祝你的项目好运。

于 2013-04-03T11:25:26.683 回答