Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-23-2006, 04:26 AM   #1
Registered: Jan 2005
Posts: 53

Rep: Reputation: 15
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

Old 11-23-2006, 04:34 AM   #2
Senior Member
Registered: Mar 2004
Location: england
Distribution: NetBSD, Void, Debian, Mint, Ubuntu, Puppy, Raspbian
Posts: 3,487

Rep: Reputation: 233Reputation: 233Reputation: 233
always use the full path: system("/blah/blah/blah/command")
Old 11-23-2006, 04:51 AM   #3
Registered: Jan 2005
Posts: 53

Original Poster
Rep: Reputation: 15
Thanks a lot, It may help for me.
Old 03-20-2007, 01:41 AM   #4
Registered: Dec 2005
Posts: 48

Rep: Reputation: 15
In ur system call, just give the absolute path of ls command.

i.e, /bin/ls

I hope it should work.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling a system call from a system call? Loc_8 Programming 0 09-16-2006 05:21 PM
System call to get current process memory usage? mattengland Programming 4 03-15-2006 08:07 PM
Is it possible to use system() and get the return value from the system call newguy21 Programming 1 08-11-2004 02:37 PM
System call dami Linux - General 0 11-18-2003 12:18 PM
Using the "system( )" system call causes exit sometimes AbhiShek Linux - Software 6 10-01-2002 03:56 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:50 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration