Hi Jon, Depends on the file. You certainly can use run('cat') and then interact with the stdout value (run()'s return acts like a string containing stdout, by default).
For anything that doesn't play nice with that (e.g. funky nonprinting characters) the put/get functions can take StringIO arguments for the 'local' side of things, so you should be able to do e.g.: contents = StringIO() get('/path/to/file', contents) # operate on 'contents' like a file object here, e.g. 'print contents.getvalue()' -Jeff On Thu, Oct 10, 2013 at 4:16 AM, Jon Dufresne <jon.dufre...@gmail.com> wrote: > Hi, > > What is considered the best way to read a remote file into memory to > be used by Python or Fabric? Should I shell out to cat on the server > "contents = run('cat /path/to/file')" or is there a better way? > > My Fabric file requires parsing a file to continue other operations on > the server. > > Thanks, > Jon > > _______________________________________________ > Fab-user mailing list > Fab-user@nongnu.org > https://lists.nongnu.org/mailman/listinfo/fab-user -- Jeff Forcier Unix sysadmin; Python/Ruby engineer http://bitprophet.org _______________________________________________ Fab-user mailing list Fab-user@nongnu.org https://lists.nongnu.org/mailman/listinfo/fab-user