Reputation: 3748
How can I call a function from a python script (Ubuntu shell) but also pass a config parameter at the same time? A relevant SO post does not seem to address that.
This is what I have for now:
$ python -c ' from python_library import * ; function() ; -config /path/to/config/file '
The above fails. And so do the following (as many other) combinations:
$ python -c ' from python_library import * ; function() -config /path/to/config/file '
or
$ python -c ' from python_library import * ; function() ; -config "/path/to/config/file" '
Thanks!
Upvotes: 0
Views: 405
Reputation: 2246
You need to pull the conf arg out as another argument to python
$ python -c ' from python_library import * ; function()' -config /path/to/config/file
Upvotes: 1
Reputation: 195573
You could use environment variable for that:
MYPARAMETERS="-config /path/to/config/file" python -c "import os,sys;sys.argv = os.environ['MYPARAMETERS'].split(); import python_library import * ; function()"
Upvotes: 1