Notifications
Clear all

[Mark Solved / Archieved] Can't execute "runScript.sh" from C++

3 Posts
2 Users
0 Reactions
329 Views
(@larry_gorham)
Posts: 9
Active Member Customer
Topic starter
 

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

 
Posted : 26/01/2025 3:53 pm
(@larry_gorham)
Posts: 9
Active Member Customer
Topic starter
 

Sorry Folks, I forgot about the exec command.  That works fine. - Larry

std::system("exec /home/larry/wittypi/runScript.sh & "); // execute this from bash

 
Posted : 27/01/2025 5:27 am
(@admin)
Posts: 625
Member Admin
 

@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.

 
Posted : 27/01/2025 10:14 am
Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.