Running shell script in rails only outputs the 1 l

2019-06-05 15:41发布

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'...

1条回答
啃猪蹄的小仙女
2楼-- · 2019-06-05 16:14

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).

查看更多
登录 后发表回答