Bash node flow Variable

Hi all,

I'm trying to recall a flow variable in a bash command of the bash node.

Which is the correct way to do it?

I've a flow variable dir that has a value /home/myname.

Let's say I want to list it and put the output to a file:

ls $dir > file.txt

don't work. The var is not recognized. I'm testing the way by echo command, but I still cannot find the right way. What's the right syntax accepted by this node/knime?

Thanks and sorry if this is a too much basic question

Thanks

Andrea

 

 

Hi Andrea,

Thank you for your question. One way of doing that is like this: use the String manipulation (Variable) node where you can create the complete bash command including the flowvariable (something like join(“ls”, $${dir}$$, “> file.txt”)). Subsequently you can use that command as variable for the Bash command (in the flow variables option B_cmd). Does that help?

Let me know if you have further questions,
Jeany

1 Like

Hi Jeany, thanks for the reply.
I’ve been working that way and it goes…however I was thinking in something “direct” in the bash node…It would be certainly faster than creating the commands “outside”. There’s no way of reading/use the flow variables inside the bash node?
Thanks again
Andrea

Yes, that would certainly be nice to have, unfortunately this is not possible at the moment in the bash node. The nodes External tool (labs) and External tool offer a little more flexibility on the parameters. You might take a look at them in case creating the command with the String manipulation node costs too much time.
Best,
Jeany