[Buildbot-devel] Mac's "cat" behaves strangely if encapsulated in buildbot's ShellCommand

Greg Ward greg at gerg.ca
Wed Jul 14 12:37:46 UTC 2010


On Thu, Jul 8, 2010 at 5:28 PM, David Mor <david.mor at mobidia.com> wrote:
> Before upgrading, I would like to solve the current issue I encountered.
>
> I was trying to use issue a "cat" command and a "rm" command to print and
> delete multiple textfiles on
>
> Mac OS X  by writing the following in master.cfg
>
> printMicSummaryStep = \
>     ShellCommand(description="Printing MicSummary",
>                  descriptionDone="Printed MicSummary",
>                  command=["cat", "micsummary*.txt"],
>                  workdir=[workdir])
> deleteMicSummaryStep = \
>     ShellCommand(description="Deleting MicSummary",
>                  descriptionDone="Deleted MicSummary",
>                  command=["rm", "micsummary*.txt"],
>                  workdir=[workdir])
[...]
> For some reason I could manually run the command successfully, but
>
> I consistently get the following error:
>
> "No such file or directory"
>
> Is there something that I'm misunderstanding or doing wrong?

Yes, you are.  This is a very frequently-asked question.  To my
surprise, I did not see it answered in the BuildBot FAQ
(http://buildbot.net/trac/wiki/FAQ).

It is covered, although a bit obliquely, in the manual:

  http://buildbot.net/buildbot/docs/current/Using-ShellCommands.html#Using-ShellCommands

See under 'command'.

Here is my attempt at an FAQ entry:

"""
  Why don't wildcards work in my ShellCommand?

  Probably because your build slave is running a Unix variant and you
wrote your
  command in the recommended way, as a list:

    factory.addStep(ShellCommand(
        command=["rm", "*.old"],
        ...))

  The advantage of writing your command as a list is that it is
executed directly
  by BuildBot, without a shell getting in the way.  That means you won't have
  problems with quoting or whitespace in filenames.  But since there is no shell
  involved, it also means that wildcards will not be expanded: BuildBot simply
  passes the string `*.old` to `rm`, which complains because there is
no such file.

  The solution is to specify your command as a string, so it will be run by
  `/bin/sh`:

    factory.addStep(ShellCommand(
        command="rm *.old",
        ...))

   However, this can introduce all the classic shell quoting nightmares.
"""

Please suggest improvements!  I'll add this to the FAQ soon.

Greg




More information about the devel mailing list