The problem is as follows:
I have a task to write a driver for a quartz clock on a Raspberry Pi, the driver should allow concurrent access for reading/writing. Therefore I used semaphores to block access.
Now I want to test this, therefore I have to run
sudo hwclock -r -f ...
My idea was to write a program in C to make this test automatic, and use fork to run access concurrently. But I cannot run the program as superuser since I don't have those permissions on the Pi.
What I tried to do was:
system("echo pass\"word | sudo -S hwclock --set --date \"7/20/37 12:00:00\" -f /dev/<device>");
and
system("echo pass\x22word | sudo -S hwclock --set --date \"7/20/37 12:00:00\" -f /dev/<device>");
both give me the error
sh: 1: Syntax error: Unterminated quoated string
Running the program with "password" instead of "pass\"word" works without the error.
So what I need is some way to let the program "enter" the password for me.
Hopefully, someone can help me with this or point me in the right direction. Other ways to accomplish testing this are appreciated.