@suchalaugh said in [Solved] How to write variable value to file?:
Sorry for warming, i still dont get it. I have a string variable in pimatic, it’s name is $teamsoll
And when I hit a button, i want to write that variable into a textfile, e.g. /home/foo/scripts/football/team.txt
I tried many ways, including the above, either with a rule or with a shellbuttondevice, i failed. Can somebody help me?
It is all about the “quotes”…
When yourbutton is pressed then
execute "echo '$teamsoll' > /home/foo/scripts/football/team.txt"
Everytime the button is pressed, it will replace the first line in team.txt with the variable.
If you want it like this:
Team1
Team2
Team3
Then, add another > so it becomes echo '$teamsoll' >> /home/foo/scripts/football/team.txt