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 ...
- 04-02-2011 #1Just Joined!
- Join Date
- Jul 2010
- Posts
- 2
Make system call from an automatically started daemon...
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 is started manually, everything works fine.
If it is started per script on startup, the following system call doesn't work :
the returned rc in this case is 256.Code: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 ?
thanks !
- 04-05-2011 #2Linux Newbie
- Join Date
- Nov 2008
- Location
- Tokyo, Japan
- Posts
- 243
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:then grep for "MY_PROGRAM" in /var/log/messagesCode:fprintf(stderr, "MY_PROGRAM: %s\n", strerror(errno));


Reply With Quote