Page 1 of 1

[Execute command] problem: new line on the end of output

Posted: 19 Mar 2019 16:44
by kamil_w
Hi,
I am trying to create "an application" in Automagic with possibility to change the language of UI. So I have some text files in format:

variable_name=text string

To convert text from files into global_variables I use an action "Execute command" with command:

grep "global_variable" /patch/{value}.lang | cut -d "=" -f 2

And in field "Variable to store the standard output" I put "global_variable".

It works, but the global_variable is filled by text with new line which cause me some issues.

Instead of:
"Text string"

I get

"Text string

"

Does anyone know how to fix it or how to get strings for variables from txtfile in different way?

Re: [Execute command] problem: new line on the end of output

Posted: 19 Mar 2019 22:23
by kamil_w
I found solution. :)

Action script:
global_value = trim(global_value)

Re: [Execute command] problem: new line on the end of output

Posted: 20 Mar 2019 15:48
by Desmanto
To get text from files, we usually just action init variable text file, although that is limited to 1 MB files only. To get the string you want, probably it is much easier to use regex. findAll() is one the function I use a lot to parse those kind of text.

Re: [Execute command] problem: new line on the end of output

Posted: 21 Mar 2019 00:29
by kamil_w
Thanks.
Works like a charm. :)