Eaton Emmerich
Eaton Emmerich

Reputation: 539

Python Fabric on FreeBSD cannot execute Binary

My simple Fab file cannot be run on my FreeBSD system:

from fabric.api import run, env
env.shell = '/usr/local/bin/bash'   #Fabric doesn't know where to get bash on BSD correctly

def host_type():
    run('uname')

First I get an error about the shell, which I can fix by specifying the shell variable as shown. But then I still have the error:

/usr/bin/uname: /usr/bin/uname: cannot execute binary file.

Upvotes: 1

Views: 302

Answers (1)

Eaton Emmerich
Eaton Emmerich

Reputation: 539

It seems like according to the man pages of bash(1):

Bash is an sh-compatible command language interpreter that executes commands read from the start input or from a file.

Meaning the only input we can give bash is a script or input via a stdin pipe. But with the -c option:

-c If the -c option is present, then commands are read from the first non-option argument command_string,...

So the solution be to use the shell with the -c option is as follows:

env.shell = '/usr/local/bin/bash -c'

And then works perfectly, I don't know why the shell for fabric is so strange for a unix system when it's intended to work on servers.

Upvotes: 2

Related Questions