LUA command shell using basic commands

I have started experimenting with lua scripts using the lua console for basic commands and have ran into a road block and not sure why.

os.forkexec ("/usr/bin/linuxsampler")
ARDOUR.LuaAPI.usleep (10000000)
os.forkexec ("/usr/local/bin/send_lscp ~/audio-projects/QSampler/test.lscp")
-- os.forkexec ("nc localhost 8888 < ~/audio-projects/QSampler/rockdrums.lscp")

The first line does work and starts LinuxSampler, as does usleep. However I am unable to send it a lscp script with the following line. I have tried with both a helper script (send_lscp) and directly via netcat with no results or errors either for that matter.

EDIT: Using Ardour 8.12 for these tests.

Any tips or advice most appreciated!

exec here is a low level exec(3 posix) system call. To expand shell arguments like ~/ you need a shell. Try

os.forkexec ("/bin/sh", "-c", "/usr/local/bin/send_lscp ~/audio-projects/QSampler/test.lscp")

Ah, this worked! Thank you Robin very much for that. My goal is to create a lua script that can basically replace qsampler or fantasia and make something that is usable from within Ardour/MB. The first step was obviously being able to communicate with linuxsampler.

Next is to make this work with the linuxsampler process spawned by the LV2 plugin.