Cool stuff for Raspberry Pi, Arduino and all electronics hobby projects
Notifications
Clear all

Can't execute "runScript.sh" from C++

3 Posts
2 Users
0 Likes
40 Views
(@larry_gorham)
Posts: 3
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 2:53 pm
(@larry_gorham)
Posts: 3
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 4:27 am
(@admin)
Posts: 527
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 9:14 am
Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.