LinuxQuestions.org
Visit Jeremy's Blog.
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 05-21-2010, 09:04 AM   #1
eng_suha
LQ Newbie
 
Registered: Apr 2010
Posts: 10

Rep: Reputation: 0
Unhappy terminal command in c program


hi guys

I want to design c program can run terminal command and put the output of command into file... How can i do this ?

for example :

string s = " iwlist scan "

and when i run the programm this command applied and put the output into specific file

plz help me
 
Old 05-21-2010, 11:09 AM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Been a while since I did c, but i believe you're looking for the "system" call, as for putting it in a specific file... you could just specify it in the command itself--

system("/usr/local/sbin/command > /tmp/out-file");

Generally speaking, its far easier to write a bash or perl script than a c program when you're heavily interacting with system and you may want to look at those routes depending on what the end goal is here.

Last edited by rweaver; 05-21-2010 at 11:10 AM.
 
  


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
How do I resize the terminal window from the command line in the gnome terminal QuIcKSpArK Linux - Newbie 5 04-21-2012 02:04 PM
[SOLVED] Make linux terminal transparent with terminal command? yooy Linux - Newbie 1 05-11-2010 03:24 AM
[SOLVED] append command output to file by giving command in terminal sumeet inani Linux - Newbie 4 07-03-2009 10:36 AM
Running program from terminal with & does nothing, program stops DittoAlex Linux - General 1 10-05-2007 01:35 AM
Command or program to view pics from terminal gonus Linux - Software 5 06-29-2006 04:14 PM

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

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