LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   system system call usage (https://www.linuxquestions.org/questions/programming-9/system-system-call-usage-504150/)

sureshkellemane 11-23-2006 03:26 AM

system system call usage
 
Hi All,

I am facing one problem with system function call.

I have used the system function call in my program like
system("ls -R | grep \"old\"") and based on the return value I take some decision.
I have compiled and copied to /usr/bin. My program name is MyProgram.

Since I have used ls here and It gives me proper listing.

But after few days or some time, it stops suddenly working ... it says
sh: ls:command not found

I donnaaa what is happening here ... Is it the problem with the usage of the system function call or something else. I am not able to debug what is happening.

But if I recopy MyProgram binary to /usr/bin again... It works fine.

Please help me. I am using FC 4

Thanks,
Suresh

bigearsbilly 11-23-2006 03:34 AM

always use the full path: system("/blah/blah/blah/command")

sureshkellemane 11-23-2006 03:51 AM

Thanks a lot, It may help for me.

sharad 03-20-2007 12:41 AM

In ur system call, just give the absolute path of ls command.

i.e, /bin/ls

I hope it should work.


All times are GMT -5. The time now is 02:17 PM.