473,748 Members | 7,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Extracting output from system(3) call

is there any standard way to extract output from system(3) function?
TIA.

May 13 '06 #1
18 1668
if possible to use pipe(2) how could file descriptor can be derived
from file pointer, FILE *. TIA.

May 13 '06 #2
am going to use

system("ls > /tmp/t");

May 13 '06 #3
v4vijayakumar wrote:
is there any standard way to extract output from system(3) function?
TIA.


<OT>
In a Posix system, use popen(3) instead
</OT>

Robert
May 13 '06 #4
"v4vijayaku mar" <v4***********@ yahoo.com> writes:
is there any standard way to extract output from system(3) function?
TIA.


The C standard doesn't provide any way to do this, but your
implementation might. Try a system-specific newsgroup.

But first, please read <http://cfaj.freeshell. org/google/>.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
May 13 '06 #5
Robert Harris wrote:
v4vijayakumar wrote:
is there any standard way to extract output from system(3) function?
TIA.

<OT>
In a Posix system, use popen(3) instead
</OT>


BTW: What is Posix???
Best regards / Med venlig hilsen
Martin Jørgensen

--
---------------------------------------------------------------------------
Home of Martin Jørgensen - http://www.martinjoergensen.dk
May 13 '06 #6
"v4vijayaku mar" <v4***********@ yahoo.com> wrote:
# is there any standard way to extract output from system(3) function?

You have to save the output to a file within the command line,
and then open the file subsequently.
For example on unix, you can do something like
if (system("cat gloober/* >fripper")!=0 ) error(...);
FILE *fripper = fopen("fripper" ,"r");
...
fclose(fripper) ;

POSIX systems also provide popen/pclose.
FILE *fripper = popen("cat gloober/*","r");
...
if (pclose(fripper )!=0) error(...);

--
SM Ryan http://www.rawbw.com/~wyrmwif/
But I do believe in this.
May 13 '06 #7

"Martin Jørgensen" <un*********@sp am.jay.net> wrote in message
news:08******** ****@news.tdc.d k...
Robert Harris wrote:
v4vijayakumar wrote:
is there any standard way to extract output from system(3) function?
TIA.

<OT>
In a Posix system, use popen(3) instead
</OT>


BTW: What is Posix???


http://en.wikipedia.org/wiki/POSIX

-Mike
May 13 '06 #8
It seems that there is another way.

fclose (stdout);
stdout = fopen ("standard-output-file", "w");

system("ls");

/* process output file here */

May 15 '06 #9
v4vijayakumar wrote:
It seems that there is another way.
Another way to do what? Google is most definitely *not* Usenet, just an
interface that dupes people in to making incorrect assumptions. Read
http://clc-wiki.net/wiki/Intro_to_clc and provide context in future.
fclose (stdout);
stdout = fopen ("standard-output-file", "w");

system("ls");

/* process output file here */


I've got no idea what you think the above will do, but I doubt it will
actually do what you think. For a start, there is no guarantee that
changing stdout within a program will affect where the output of a
program invoked using system goes.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
May 15 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
3677
by: Calvin FONG | last post by:
Dear all, Are there any utility that can be call by python to create self extracting zip file. I'm now using the powerarchiever. But the command line options aren't flexible enough. Basically, I would like to create a self extracting zip with default file path extraction and force over-write. The powerArchiever just don't let me call it unless I'm using the GUI. Any idea, experience and suggestion are welcome. Thank you. -Calvin
0
2946
by: Gnaneshwar Babu | last post by:
Hi I am facing a problem with extracting event logs of win32 to a file. Am using the following code to extract eventlogs to file use Win32::EventLog; $handle=Win32::EventLog->new("System", $ENV{ComputerName}) or die "Can't open Application EventLog\n"; $handle->GetNumber($recs) or die "Can't get number of EventLog records\n";
6
2566
by: Andrew Edwards | last post by:
I have program that downloads a file from the internet and extracts it using calls to system(). All files are extracted into the directory where my program is located. How do I redirect the extracted files to a specified directory? I can use the following: system("move *.* c:\directory"); However, this will move my program. I end up having to call system for every
13
15980
by: Kosio | last post by:
Hello, I know of a way to extract digits from a number using the %10 and divide by 10. But I am wondering if there is an algorithm out there that does not use a divide by 10 feature. The reason I ask is that I am programming on a RISC system where division is quite expensive, and I want to be able to extract the digits from an integer (the integer will be from 1 to 6 digits long, and I know how many digits are in the number).
2
2814
by: Dickyb | last post by:
Extracting an Icon and Placing It On The Desktop (C# Language) I constructed a suite of programs in C++ several years ago that handle my financial portfolio, and now I have converted them to C#. The only significant problem that I have encountered in the conversion is this one - extracting an icon from the 'KTEntryPoint' program into the software suite and placing that icon on the PC Desktop.
2
1474
by: Russ | last post by:
Hi, I have created a Table webcontrol dynamically using code. Before rendering it, I need to get at the HTML and do a couple of things manually. I've tried a couple of methods to extract the HTML but things aren't working as expected. Dim W As New System.IO.StringWriter Dim TS As New HtmlTextWriter(W) Dim S as String
4
2783
by: Debbiedo | last post by:
My software program outputs an XML Driving Directions file that I need to input into an Access table (although if need be I can import a dbf or xls) so that I can relate one of the fields (fromStop) and its associated driving directions back to a relational database. I have asked my software vendor for solutions but thus far they have not come up with anything. I am totally unfamiliar with XML so I am struggling with how to do this. I have...
1
1249
Echooff3
by: Echooff3 | last post by:
Here's a function I created to write embedded resource files into whatever file you need it to go. I used it to retrieve an embedded word document and write it to a temp folder. Public Sub CreateFileFromResourceFile(ByVal pIn As String, ByVal pOut As String) Dim currAssembly As Reflection.Assembly Dim input As Stream Dim output As Stream Dim Buffer(20000) As Byte Dim read As Integer
4
2010
by: billiejoex | last post by:
Hi there, I'm facing a case where I need to get the traceback outptut when occurring an exception. I solved such problem by using traceback module in conjunction with StringIO: import StringIO, traceback try: raise Exception except:
0
8831
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9325
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.