Attached a POC for a new command: "setcmd variablename = shellcommand shellargs"
Directly get the first line of a shell commands output. Only a POC, untested, unchecked if secure, unchecked for memory leaks ... I'm not a c programmer ...
It would be nice if multiline results are supported too as array ...
An example console output:
ngspice 8427 -> shell cat t.pl #!/usr/bin/perl printf("%f\n", 5.38135e+006/1000000); ngspice 8428 -> setcmd myvar=perl ./t.pl setcmd: 1 <myvar=perl ./t.pl> setcmd: 2 <myvar> <perl ./t.pl> setcmd: 3 var=<myvar> result=<5.381350> ngspice 8429 -> set ... myvar 5.381350 ...
BR, Toni
On 2019-02-07 17:08, astx wrote:
Did you know this one:
-marcel
Related
Patches: #32
No - didn't know, that backticks are working partially. Couldn't find any hint in the manual. Sorry I haven't read it completely line by line - only searched for "backtick".
Fine that it's supported! For a single value it is usable, but - compared are the results here on string operation:
BR, Toni
Aaahhh: in the manual at 17.10 there is a hint for "backquote" - I searched for "backtick"
... the corresponding file is "src/frontend/parser/backq.c"
Look same, but isn't (CP_LIST versus CP_STRING)
With backquotes the myvar1 is converted to an array, with poc "setcmd" the string stays untouched.
String/array handling is very confusing ...
IMHO: if a program returns a string it should stay a string. To convert a string to an array a function should be used. E.g.: perl uses the "split" command to convert a string to an array.
Will take a closer look to the backquote/backtick feature.
BR, Toni