开发者

How do I get Hudson to stop escaping parts of my shell script?

I would like to have a shell script that copies some logs from a part of my system to the hudson workspace so I can archive them.

So right now I have

#!/bin/bash -ex
cp /directory/structure/*.log .

This is kind enough to be changed to

cp '/directory/structure/*.log' 开发者_运维问答.

Which of course is not found since I don't have a file named *.log.

So how do I get this script to work?

EDIT So I left out the part that I was using sudo cp /path/*.log, because I didn't think that would matter. Of course it does and sudo is the issue not hudson.


One simple answer would be to have the shell script in a separate file, and have hudson call that.


sudo bash -c "cp /directory/structure/*.log"


Throwing it out there, but haven't had a chance to try it in Hudson (so I don't know how it gets quoted):

for f in /directory/structure/*.log ; do
    cp $f .
done

In my simple test in a bash shell, different quoting options produce either one or multiple invocations of the copy command (either with all matching files or one at a time), but they all manage to do the copy successfully.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜