This works just fine
@task
def foo(context):
with context.cd('/'):
context.run('pwd')
Output:
/
But this does not:
@task
def bar(context):
with context.cd('/'):
context.sudo('pwd', password='mysecretpassword')
Output:
[sudo] password: sudo: cd: Befehl nicht gefunden
How do I get the second example to run?
It turns out, that this is a bug in invoke yet to be fixed.
https://github.com/pyinvoke/invoke/issues/459
Edit:
This is my workaround for now:
context.sudo('bash -c cd "/ && pwd"')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With