How to parse item's state to .sh script file?

As the title said, can anyone show me how to parse an item’s state or values to .sh script file using exec binding ??
For example, I have a switch item and a string (or number) item, I want to parse their state/values to .sh file so that I can implement several tasks. How can I do that?
Thanks in advance.
note: I am having OH 1.8.3 server on Raspberry Pi 3 Raspbian Jessie

Any idea please?

You cannot do it using the exec binding. You have to create a Rule and use executeCommandLine. Then you can do something like

val results = executeCommandLine("command to execute " + MyItem.state.toString, 5000)
logInfo("exec", results)
1 Like

What if in my command require quotation marks, for example: epeak “Hello world”, then what is the syntax?

Just escape the quotes:

"speak \"Hello World\""