Hello Nice Tool Folks
I'm testing two WittyPi 4's on Raspi 4b's bullseye and bookworm. I also need to reschedule every day as in your response to Spknmmike which is no problem since runScript.sh runs every startup. However, for testing I want to execute runScript.sh from C++ and instantiate the next schedule without rebooting. I have tried:
std::system("./home/larry/wittypi/runScript.sh & "); // execute this from bash
std::system("./home/larry/wittypi/runScript.sh "); // execute this from bash
std::system(". /home/larry/wittypi/runScript.sh & "); // execute this from bash
std::system(". /home/larry/wittypi/runScript.sh "); // execute this from bash
and using myRunScript.sh with included runScript.sh code:
std::system(". /home/larry/wittypi/myRunScript.sh "); // execute this from bash
These all gave errors with varying explanations and the last was kind of funny. Any suggestions?
Regards,
Larry
Sorry Folks, I forgot about the exec command. That works fine. - Larry
std::system("exec /home/larry/wittypi/runScript.sh & "); // execute this from bash
@larry_gorham This topic is about generic programing with C++ in Linux, and is not specifically about UUGear product. However it might be helpful to other users, so I would share my thought here.
The problem most probably comes from the '.' in your std::system() calls. Some have a space between '.' and "/home/larry/wittypi/runScript.sh" while some don't. The '.' should not be used there. The script should be executed if you remove the '.' from std::system() call.