views:

97

answers:

3

I have a Python script gathering info from some remote network devices. The output can be maybe 20 to 1000 lines of text. This then goes into excel on my local PC for now.

Now access to this Linux device is convoluted, a citrix session to a remote windows server then ssh to the Linux device half way around the world. There is no ftp, scp, or anything like that, so I can't generate the excel on the Linux device and transfer it locally. The ONLY way to get the info is to copy/paste from the ssh window into the local machine and post-process it

My question is what would be the best (from a user point of view as others will be using it) format to generate? 1.as it is now (spaces & tabs), 2.reformat as csv or as 3.convert to xml

+7  A: 

CSV is more robust than your current format under "copy and paste transfer" -- spaces and tabs can easily get confused, commas and doublequotes aren't. And the Python standard library's csv module makes it pretty easy to solidly generate good CSV output.

Alex Martelli
OK Thanks - there's really no advantage of moving to xml, but many advantages of not sticking to tab/space
A: 

Reformat it as CSV. It's dead easy to do, is fairly human readable, and can be read by loads of pieces of spreadsheet software.

Martin
A: 

Are you sure copy-paste is the only way? If you can interactively ssh to the Linux device, then you can also ssh plus run a command plus redirect the output. So:

ssh remote-linux-box command-to-run >output-file

This doesn't involve any manual copy and paste at all.

Greg Hewgill
I generate the output on the Linux box locally as you say above. At that point I have the file on the box - only accessible via citrix - and scp/ftp etc are denied. In fact I can't create files on the citrix server
I see what you're saying (especially about not being able to create files on the citrix server, that's an unfortunate restriction). However, note that the redirect in my example above applies to the box on which you run ssh, *not* to the remote-linux-box. Redirecting on the remote linux box would require quotes around the redirection: ssh remote-linux-box "command-to-run >output-file"
Greg Hewgill