Skip to content

BashScripting

Jim Saxton edited this page May 13, 2016 · 4 revisions

Bash Scripting

Yoshi is intended to be a GUI add-on for your scripts.

Calling yoshi

Yoshi should be in the path, so there is no need to specify the path to the program. If your command file is in ~/config/settings/fatelk/yoshi/commands then there is no need to specify the path for the command file either.

yoshi MyCommandfile>/tmp/yoshout

This will envoke yoshi and send the output to the "/tmp/yoshout" file.

Reading the yoshi output

while IFS='' read -r line || [[ -n "$line" ]]; do
	var1=$(echo $line | cut -f1 -d=)
	var2=$(echo $line | cut -f2 -d=)
	eval $var1='$var2' 
done < "/tmp/yoshout"

This will read the yoshout file and place the data in the variables. Yoshi outputs data like this:

element=outputdata

Where element is the name you gave your cointrol and outpuitdata is the value the user entered. The element side becomes the bash variable name, and the outpuitdata side is stored in the variable.

If the the command file contains:

tx.type = textfield
tx.label = Name :

And the user types "My Name" in the text field, yoshi will return:

tx=My Name

$tx will be created and set to "My Name"

echo $tx

prints

My Name

next one should delete the yoshout file:

rm /tmp/yoshout

See the yoshitest.sh script in the Example directory for a complete example.

Back