Results 1 to 2 of 2
Hi, i've the following problem : i've written small tool in C which makes measurements on my router (OpenWrt White Russian). It is working as a deamon. If the tool ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 04-02-2011 #1
- Join Date
- Jul 2010
Make system call from an automatically started daemon...
i've written small tool in C which makes measurements on my router (OpenWrt White Russian).
It is working as a deamon. If the tool is started manually, everything works fine.
If it is started per script on startup, the following system call doesn't work :
sprintf(command,"/bin/cat /root/%s%s | /usr/bin/ssh -p2222 user(at)host -i /root/.ssh/id_rsa \"/bin/cat >> result/%s%s\"", apmac, source, apmac, dest); rc = system (command);
first i thought it is a problems with the user rights for the tool, so i have added +s to it. but that didn't help. as i said, when the daemon is started by hand, the system call works fine.
any suggestions ?
- 04-05-2011 #2
- Join Date
- Nov 2008
- Tokyo, Japan
It might be user rights for the "result/apmacdest" file to which you append. Either the directory doesn't exist, or you don't have write permissions. Shouldn't you instead append to a file in "/var/log"?
It could also be possible that "ssh" requires services that are not yet available at start-up time. Make sure the script that executes your program is in the correct runlevel and executes after all necessary services have started. If your Linux supports a "system services" interface, write a service to execute your program, make this service dependent on ssh client services.
Also, consider writing debug code like:Code:
fprintf(stderr, "MY_PROGRAM: %s\n", strerror(errno));