C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-21-2002, 02:10 PM   #1
Registered User
 
Join Date: Oct 2001
Posts: 2
System Commands Output

I want to save the output of system command in the memory location.For example the following command will save the output in the file /tmp/lsfile.txt.

system("ls -al > /tmp/lsfile.txt");

Rather than saving it in file is it possible to save it in some string variable or any other data structure?Does any on know?
nasir_qau is offline   Reply With Quote
Old 03-21-2002, 02:14 PM   #2
muttski
Guest
 
Posts: n/a
There probly is, but if you want a temporary solution just load the file.
  Reply With Quote
Old 03-21-2002, 03:14 PM   #3
Registered User
 
alex's Avatar
 
Join Date: Sep 2001
Posts: 132
Yes there is. try this:
Code:
FILE *fp;

fp=popen("ls -al", "r");

/* read from "fp" using f***-functions */

pclose(fp);
alex
alex is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
System commands Tropicalia C++ Programming 3 09-30-2006 11:18 AM
retrieve output from system() mmongoose C++ Programming 5 12-15-2005 06:44 AM
system commands. deletion of file after program terminates xddxogm3 C++ Programming 12 11-24-2003 10:41 PM
string variables and system commands part 2 Unregistered A Brief History of Cprogramming.com 1 10-25-2001 12:57 AM
string variables in system commands Unregistered A Brief History of Cprogramming.com 3 10-24-2001 12:36 PM


All times are GMT -6. The time now is 09:06 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22