LinuxQuestions.org
Visit Jeremy's Blog.
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 08-28-2009, 02:07 PM   #1
rajdey1
LQ Newbie
 
Registered: Nov 2008
Posts: 4

Rep: Reputation: 0
how to capture the output of a command run throug execl()


hi
I am newbie in linux i am writting a c program under linux enviroment .........my need is to run the ping command through execl() the excat code is

execl("/sbin/ping","ping","-c 4","-q","192.168.0.8",(char *) 0);

now i need to capture the output of the ping command in a file instead of in terminal ........please help me to code it
 
Old 08-29-2009, 10:26 AM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
How about using popen instead?

This would be trivial in a shell script. Why do you have the requirement to use C? Homework?
 
Old 08-29-2009, 10:42 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Yes---almost certainly homework.....see posting history

rajdey1;

In your other two posts---almost a year ago---you never responded to questions or posted follow-up of any kind. Both of those threads appeared to be homework also.

If you want help here, you have to respond to people's posts. In this case, crabboy has asked one specific question. I'd also like hear what the context for your question is---i.e. what is the overall objective / problem.
 
Old 08-30-2009, 02:03 PM   #4
rajdey1
LQ Newbie
 
Registered: Nov 2008
Posts: 4

Original Poster
Rep: Reputation: 0
its not home work

hi
frist of all let me make it clear its not home work ............i m new bie in linux but have good knowledge in c under windows........i am writing a program in c which is to be implemented in NIS server but i m stuck at that point..............the method to capture the output of a ping command as stated earlier ...................


Reagarding my previous post at that time i was jus trying to gather knowledge of linux as i was shifted to new project.............but i solved all the question ......moments i posted the post ...........a linux guru in another forum was very much helpfull
 
  


Reply


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
Perl - how to capture output of a command with more than one args new_2_unix Linux - Newbie 2 11-29-2007 11:55 PM
Capture partial output from `date` command tekmann33 Linux - Newbie 7 12-27-2006 02:09 PM
How to get the execl() output? estratos Programming 4 06-07-2006 06:18 PM
can't capture 'at' command standard output to a file bartoni Linux - General 3 02-28-2006 04:52 PM
Can I put execl command output into a file? CrazyDragon Programming 1 12-17-2003 05:34 AM

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

All times are GMT -5. The time now is 05:49 AM.

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