Hi Edoardo,

On Tue, Feb 16, 2010 at 6:57 AM, Edoardo Batini <eod...@gmail.com> wrote:
> Hi,
> which is the best way to edit remote files using fabric?

There's no way to run fully interactive programs with Fabric at this
time, so unfortunately you'll have to come up with some noninteractive
method of effecting changes to remote files.

I often use fabric.contrib.files.(sed|append|comment|uncomment) to
script minor changes to remote files; and of course there's the main
API calls get()/put() for upload/download. Depending on your needs,
you might want to consider using prompt() or local() alongside the
abovementioned functions.

E.g. if you need to make simple-but-unscriptable changes, get some
input from the user with prompt() and use that in a call to sed(). Or,
more robustly, write a helper function (semi-pseudocode):

    def edit(remote_path):
        local_path = tmpfile(remote_path)
        get(remote_path, local_path)
        local("vim %s" % local_path)
        put(remote_path, local_path)

(In fact, I could easily see such a function showing up in
fabric.contrib.files, at least if no fully-interactive mode is
implemented in the near future.)

Hope that helps,
Jeff

-- 
Jeff Forcier
Unix sysadmin; Python/Ruby developer
http://bitprophet.org


_______________________________________________
Fab-user mailing list
Fab-user@nongnu.org
http://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to