LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-03-2006, 02:21 AM   #1
bhuvana
LQ Newbie
 
Registered: Dec 2004
Posts: 7

Rep: Reputation: 0
redirection


hello...
how can i redirect the output of a command into a file in a c program..(not at the command prompt)
when i used "top>filename" inside a popen command it was giving an error..
can u please help me....
thanku.
 
Old 07-03-2006, 02:36 AM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
Posts: 1,900

Rep: Reputation: 69
1. system()
2. create pipe. fork. Redirect (with dup2) in/out/err of child to file/from pipe. exec()
 
Old 07-03-2006, 02:36 AM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well firstly tell us what the error is, we're not psychic... and also top is an interactive program, so doesn't make sense to use in this way, you'd use options like "-n1" to make it only show output once and terminate
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wget and redirection EmOuBi Linux - Software 6 01-09-2013 05:53 AM
Output redirection??? ed_po Linux - Newbie 3 06-13-2006 12:17 PM
what is output redirection? LinuxPadawan General 5 05-18-2005 12:53 PM
redirection in C pantera Programming 2 08-11-2004 01:06 PM
Device Redirection CPUNeck Linux - Newbie 1 12-20-2001 01:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:40 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