Hi,
I'm hoping someone has come accross this error that can help me. I'm using fabric to deploy a file to several remote servers. So I created a function in my fabfile.py that takes care of this for me when I give it the local path to get the file from. The issue is that each server gets a distinct file so I have to go through host by host since I need to generate the file for each one right before I call the put function. Bascially I have a main program that calls this fab function through a subprocess, sort of like this:
main.py
...
servers # a list that contains the ip addresses for all my servers
for server in servers:
newlist=getListPath() # I know this works, I get the right path and it's valid
subprocess.call(['fab -H %s putfile:%s'%(server, newlist)], shell=True)
fabfile.py
....
def putfile(lpath):
rpath='some/path'
put(lpath,rpath)
This is the error that I get when I run the program:
Usage: fab [options] <command>[:arg1,arg2=val2,host=foo,hosts='h1;h2',...] ...
Options:
-h, --help show this help message and exit
-V, --version show program's version number and exit
-l, --list print list of possible commands and exit
--shortlist alias for -F short --list
-F LIST_FORMAT, --list-format=LIST_FORMAT
formats --list, choices: short, normal, nested
-d COMMAND, --display=COMMAND
print detailed info about a given command and exit
-r, --reject-unknown-hosts
reject unknown hosts
-D, --disable-known-hosts
do not load user known_hosts file
-u USER, --user=USER username to use when connecting to remote hosts
-p PASSWORD, --password=PASSWORD
password for use with authentication and/or sudo
-H HOSTS, --hosts=HOSTS
comma-separated list of hosts to operate on
-R ROLES, --roles=ROLES
comma-separated list of roles to operate on
-x EXCLUDE_HOSTS, --exclude-hosts=EXCLUDE_HOSTS
comma-separated list of hosts to exclude
-i KEY_FILENAME path to SSH private key file. May be repeated.
-a, --no_agent don't use the running SSH agent
-k, --no-keys don't load private key files from ~/.ssh/
-f FABFILE, --fabfile=FABFILE
Python module file to import, e.g. '../other.py'
-w, --warn-only warn, instead of abort, when commands fail
-s SHELL, --shell=SHELL
specify a new shell, defaults to '/bin/bash -l -c'
-c RCFILE, --config=RCFILE
specify location of config file to use
--hide=LEVELS comma-separated list of output levels to hide
--show=LEVELS comma-separated list of output levels to show
--no-pty do not use pseudo-terminal in run/sudo
-P, --parallel Default to parallel execution method
-z NUM_FORKS, --pool-size=NUM_FORKS
Number of concurrent processes to use when running in
parallel
--abort-on-prompts Abort instead of prompting (for password, host, etc)
--keepalive=KEEPALIVE
enables a keepalive every n seconds
--linewise Print stdout/stderr line-by-line instead of byte-by-
byte
/bin/sh: line 1: putfile:/home/malwarerepo/malwarerepo.trustproxy.org/util/url_list_01_22_12_174134: No such file or directory
So basically it prints out all the fab options and then at the end I get the line right above. I know the file is real and it is at that location but I don't know what the printout means. This happens for each of my servers, so I know that it's going through
each one at least.
The funny thing is that I created another script that does the same thing and it works fine. The only real difference I can see is that for the one that works I don't call the getListPath() right before but give it the same path. I don't know if it matters much but in the getListPath() function I am calling local, and all it returns is a string that happens to be the local path for that list. I think I might be able to work around this by using ftp directly but I would like to know why it keeps doing this.
Also as a sidenote is there a problem for functions taking in 2 arguments? From the website I understand that you
should be able to do this:
fab somefunction:arg1, arg2
But it reads the second argument as the ',' and tells me it's not valid?
I'm using the 1.3.4 version. Thanks in advance for your help,
Max