LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 11-23-2006, 03:26 AM   #1
sureshkellemane
Member
 
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

Thanks,
Suresh
 
Old 11-23-2006, 03:34 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

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

Original Poster
Rep: Reputation: 15
Thanks a lot, It may help for me.
 
Old 03-20-2007, 12:41 AM   #4
sharad
Member
 
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.
 
  


Reply



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 04:21 PM
System call to get current process memory usage? mattengland Programming 4 03-15-2006 07:07 PM
Is it possible to use system() and get the return value from the system call newguy21 Programming 1 08-11-2004 01:37 PM
System call dami Linux - General 0 11-18-2003 11:18 AM
Using the "system( )" system call causes exit sometimes AbhiShek Linux - Software 6 10-01-2002 02:56 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:26 PM.

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