[Thread Prev][Thread Next][Index]

Re: [ferret_users] spawn command gawk string arrays



Hi -
I guess that like Ned, I'd use Ferret's string handling functions to process the string, rather than a call to awk.

  let instring = {spawn:"echo Hello ferreters"}
  let ns = STRINDEX (instring, " ")
  let a = SUBSTRING(instring, `ns+1`, `strlen(instring)`)

The string functions are listed here,
http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/handing-string-data-symbols/STRING-FUNCTIONS

Ansley

Brockmann Patrick wrote:
Hi all,

Is there a simple way to use gawk through the spawn command and get the result in string array ?

Example:

in shell
$ echo Hello ferreters |  awk '{print $2}'

in ferret
yes? spawn echo Hello ferreters | awk '{print $2}'

But how to get the result in a string array like

yes? LET a = {spawn:"ls *.nc"}
yes? LIST a

yes? let A = {spawn:"echo Hello ferreters | awk '{print $2}'"}
**ERROR: command syntax: {spawn:"echo Hello ferreters | awk '{print $2}'"}
         unclosed quotation, parenthesis, or bracket

Up to now, I have used a trick by passing by an external shell script like:
let A = {spawn:"echo Hello ferreters | awk -f get_2nd.awk"}

but that is not as easy as it could be.
Could the syntax parsing of the spawn command be changed ?

Patrick



[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement