Parsing data from an encoded file

Hi! I have a file, generated by Avid Pro Tools, that contains the username, hostname, ip address, and network device mac addresss of the machine that currently has a file open in Pro Tools. I'm trying to parse this data, but running into issues.

It's a .tmp file, and is clearly encoded in some format i'm not familar with. When I run "cat $KMVAR_tmp_file_path" in a shell script action, i see the data i need in plain text when I have "Display results in a window" selected, however, if i save the results to a variable, i get the first character, and nothing else.

I've unchecked "trim results" and it shows up the same.

When i open the file directly in TextMate, this is what it looks like:

ZS&userHostname.local192.168.1.11<MAC ADDRESS REMOVED>

Edit: The text changes depending on where it is.... so here's a screenshot from textmate:

Also... file -I $tmp_file returns application/octet-stream; charset=binary

Is there another method for me to parse this data in an accessible format to Keyboard Maestro?

1 Like

Try sending the file to strings:

strings -n 3 /path/to/file

The -n 3 bit just tells it to ignore strings under three characters in length.

This will extract the text, I'm reasonably sure…but the downside is it will extract everything it can read, so there may be a lot of text.

-rob.

1 Like

Thank you so much. That works perfectly!