[TxMt] Re: Capturing error messages

Greg web at web.knobby.ws
Sat Jul 2 21:14:11 UTC 2011


On Jun 30, 2011, at 10:42 PM, Martin Kühl wrote:

> On Thu, Jun 30, 2011 at 21:58, Greg <web at web.knobby.ws> wrote:
>> I'm running a Ruby script from TextMate and within that script call a
>> Perl script (gpsPhoto.pl) and would like to capture the error messages
>> and act on them. The messages show up in the TM Running window.
> 
> There's nothing TextMate-specific about this, you can capture those
> messages any way you would otherwise in Ruby. Which way that is depends
> on how you call the other command, e.g. with backticks you would append
> `2>&1` to the command line.
> 
> If you're unsure, [1] has a survey of ways to run subprocesses in Ruby.
> 
> HTH,
> Martin
> 
> [1] http://tech.natemurray.com/2007/03/ruby-shell-commands.html
> 
Neophyte that I am it took a little bit of thinking. Mainly was to just set the call to Perl like so:

      perlOutput = `perl \"#{gpsPhotoLoc}\"   --image \"#{imageFile}\" --gpsfile  \"#{gpxFile}\"   --timeoffset #{geoOffset} --maxtimediff #{maxTimeDiff} --maxdistance #{maxDistance}  --geoinfo wikipedia --city auto --state guess --country guess`

I didn't have the perlOutput = before. $STDERR has info when the Perl script has an error and perlOutput gives info on what happens when the script runs. So found what I was looking for. 

One question: would the `2>&1` comment still apply? It didn't make any difference when I added the 2>&1 to the end of backtick quoted line.

Learning slowly.




More information about the textmate mailing list