0
我的問題是,我的字符串是幾個字,實際上包含'
字符...所以我在如何傳遞我想要的字符串的損失。如何將字符串或列表對象作爲參數傳遞到結構?
我試圖做的事:
fab -H myhost.serv.com execute:"nc -zw1 159.1.1.1 9988 | gawk '{print $7}'","nc -zw1 159.1.1.2 9988 | gawk '{print $7}'"
然而,這種吐出:
Executing task 'execute'
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/fabric/main.py", line 743, in main
*args, **kwargs
File "/usr/lib/python2.7/dist-packages/fabric/tasks.py", line 368, in execute
multiprocessing
File "/usr/lib/python2.7/dist-packages/fabric/tasks.py", line 264, in _execute
return task.run(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/fabric/tasks.py", line 171, in run
return self.wrapped(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/fabric/decorators.py", line 175, in real_decorator
@wraps(func)
File "/usr/lib/python2.7/functools.py", line 33, in update_wrapper
setattr(wrapper, attr, getattr(wrapped, attr))
AttributeError: 'str' object has no attribute '__module__'
有沒有解決這個辦法嗎?我從一個Python腳本調用它:
fabcmd = 'fab -H ' + ','.join(servlist) + ' execute:'
for cmd in commands:
fabcmd += "\"{}\",".format(cmd)
print fabcmd
subprocess.call(fabcmd)
如果有傳我的命令列表對象結構的方式,這實際上是理想的..所以,我可能只是做類似...
fabcmd = 'fab -H ' + ','.join(servlist) + ' execute:' + commands`
可能是因爲裝飾器是從下往上執行的,返回的值傳遞給下一個裝飾器 – 2014-10-07 21:57:32