execute system command in c
Hi i need to execute the following command in c
rm /root/test.log so i have used the following code status=execl("/bin/rm","/root/test.log"); fprintf(logfile,"status %d \n",status); but still this code returns -1 which means failure.. Where am i wrong? Thx |
Hi alaios,
Try adding this after the call to execl(), it will tell you what the error was: Code:
perror("execl() failed"); |
thx but this wont help... this code is being executed by a child so i cant see the error message
|
1. I think you can use unlink to delete a file. Will it serve your purpose.
Quote:
Code:
execl ("/bin/rm", "/bin/rm", "/root/test/log", NULL); HTH |
All times are GMT -5. The time now is 04:56 PM. |