Re: How to execute shell command and store result to variable?
Posted in 1997
Hi Ehlim! Intuitively, without testing the code, I think that the solution by Joseph Cullipher (MCOUNT=`ls|wc -l`; exit $MCOUNT; ...) is the best for this instance. Bear in mind subsequent message dealing with the factor-256 problem when interpreting the RETURNING exit value. However, if one wanted to get a screenful or more of data into the 4gl app, without using C, then one way I can think of would be to write a script to send the output of the unix command to a file and then append the pipe (|) symbol to the end of every line in the file (using sed). In the 4gl app, you can then use the load command to load the lines into a temporary table, and read the data into 4gl variables from there. It's long but not as complicated as involving C coding. Look forward to seeing better solutions though. Best regards, Nigel -- +--------------------------------------------------------------------+ | Name : Edmund Nigel Gall Address: 9A Stanmore Avenue | | Title : Account Executive Port of Spain | | Company : Stratis Caribbean Ltd. Trinidad & Tobago, W.I. | | | | Contact Information: | | Office Personal | | Voice : (809) 623 6530/1 (809) 662 6611 | | Fax : (809) 623 8370 (809) 662 6611 | | Email : ngall@stratis-caribbean.com nigelg@trinidad.net | +----------------- http://www.stratis-caribbean.com -----------------+