在轨运行shell脚本只输出了1号线 [英] Running shell script in rails only outputs the 1 line
问题描述
我试图让Rails控制器拉从位斗回购的最新内容。为了在大多数情况下,这是一个成功的我,而测试的唯一的问题,我只能似乎第一行让页面输出脚本回报,这似乎不运行脚本的其余任何想法
下面是我的bash脚本
#!/斌/ bash的-l
GIT_REPO ='IMAREPO
TMP_GIT_CLONE = TEMPPATH
PUBLIC_WWW = SITEPATH如果[-d $ TMP_GIT_CLONE]。然后
室射频$ TMP_GIT_CLONE
科幻
git的克隆$ GIT_REPO $ TMP_GIT_CLONE
杰基尔构建--source $ TMP_GIT_CLONE --destination $ PUBLIC_WWW
室射频$ TMP_GIT_CLONE
出口
和在轨控制我做
@result =%×[/var/srv/pulldevelopment.sh]
而这又只是出于把一行从它
脚本
克隆到'/根的/ tmp /混帐/嗒嗒'...
块引用>解决方案是的,这是预期。默认情况下,如果标准错误连接到TTY的Git只打印进度状态。您可以在与终端重现此问题:
$ git的克隆$ GIT_REPO 2 - ;&放大器; 1 |猫
通
- 进步
来始终得到stderr流的进展状态。请参见混帐克隆(1)。I'm trying to make a rails controller pull the latest content from a repo on bit bucket. To the most part this is a success the only issue I have whilst testing I can only seem to get the page to output the first line the script returns and that seems to not run the rest of the script any ideas
Here is my bash script
#!/bin/bash -l GIT_REPO='IMAREPO' TMP_GIT_CLONE=TEMPPATH PUBLIC_WWW=SITEPATH if [ -d $TMP_GIT_CLONE ]; then rm -Rf $TMP_GIT_CLONE fi git clone $GIT_REPO $TMP_GIT_CLONE jekyll build --source $TMP_GIT_CLONE --destination $PUBLIC_WWW rm -Rf $TMP_GIT_CLONE exit
and in the rails controller I am doing
@result = %x[/var/srv/pulldevelopment.sh]
Which in turn only out put a single line from the script which is
Cloning into '/root/tmp/git/blah'...
解决方案Yes, this is expected. By default Git only prints progress status if stderr is connected to a TTY. You can reproduce this behavior in a terminal with:
$ git clone $GIT_REPO 2>&1 | cat
Pass
--progress
to always get progress status on the stderr stream. See git-clone(1).这篇关于在轨运行shell脚本只输出了1号线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!