Thank you Jeff, this is a useful hint. But unfortunately the switches don’t allow concatenated commands like shells '&&’ :-/
Ah sorry, I totally flaked on that detail. Yes, prefix() is oriented
towards shells, so it won't work there.
If you need this command prefix most/all of the time for these hosts,
you could just do something like this (possibly even importing fab's
run() as a different name and defining this as the local name 'run',
if you wanted):
def netrun(command, **kwargs):
command = "configure {0}".format(command)
return run(command, **kwargs)
Basically, regular Python tricks for working around APIs that don't
quite fit your needs, should apply here.
Best,
Jeff
Post by Jeff ForcierExecuting commands over SSH doesn't keep a real shell around (this is
true for other SSH automation too - think of it as a series of "ssh
<hostname> <command>" calls in your shell).
So - typically you have to fake it by generating prefixed commands.
E.g. Fabric's cd() helper just updates run() calls within its block so
they all actually start with "cd <path> && ...".
You can do this with arbitrary commands by using the prefix() helper -
http://docs.fabfile.org/en/1.10/api/core/context_managers.html#fabric.context_managers.prefix
Best,
Jeff
Post by Jörg SchneiderFor managing some network devices I have to send something like „configure“ command at first before I can do the real magic with fab.
Does fabric „keep“ the remote context (or „path" if you see it as „cd something“)?
J. Schneider
_______________________________________________
Fab-user mailing list
https://lists.nongnu.org/mailman/listinfo/fab-user
--
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org
--
Jeff Forcier
Unix sysadmin; Python/Ruby engineer
http://bitprophet.org