Saturday, January 16, 2021

#1 2021-01-13 01:45:47 am

olli
Member
Registered: 2008-11-01
Posts: 43

Best way to return a record/dictionary from an external shell script

I have an external command/shell script which analyses some XML files and collects a lot of information in a dictionary-type of structure { key1: value1, key2: value2, ... }.

In Applescript I can call the tool via a line like

Applescript:

set theInfo to do shell script "/path/to/my/tool"

The shell script can output its data in whatever way is convenient for the applescript

What is the best way to pass the data from the shell script to the Applescript, so that in the Applescript I receive the data as a normal record { key1: value1, key2: value2, ... }

Can I somehow make use of the do shell script's as typeclass parameter?

Offline

 

#2 2021-01-13 04:19:40 am

Otto
Member
Registered: 2020-09-18
Posts: 2

Re: Best way to return a record/dictionary from an external shell script

Format the output of the shell script as a regular record: {x:"y", z:23} and use run script on that output. Voilá a proper record!

Applescript:

set theInfo to do shell script "/path/to/my/tool"

set myInfo to run script theInfo

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)