473,397 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

result of system call

Hi there,

I'm using the system() function to call a program but would like to
get the result of this operation.

system returns an int depending on weather the command was executed
successfully of not.

How can I get a string -- or array of strings with the output of the
camming line application instead?

Thanks

Karl
Jul 19 '05 #1
5 11285
"budgie" <la***********@yahoo.com> wrote in message
news:75**************************@posting.google.c om...
[...]
How can I get a string -- or array of strings with the output of
the camming line application instead?


You would need to redirect the output of the application.
On many systems, there is a fork() function, or something
similar. In this way, your program can call another process
and control several features, such as the I/O.

Dave

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/2003
Jul 19 '05 #2
Hi,

Use
popen( "command", "r" );

then read from the returned descriptor. This method is one way either you
read or write, but it is less code than fork.

Regards, Ron AF Greve.

"budgie" <la***********@yahoo.com> wrote in message
news:75**************************@posting.google.c om...
Hi there,

I'm using the system() function to call a program but would like to
get the result of this operation.

system returns an int depending on weather the command was executed
successfully of not.

How can I get a string -- or array of strings with the output of the
camming line application instead?

Thanks

Karl

Jul 19 '05 #3
WW
Moonlit wrote:
Hi,

Use
popen( "command", "r" );

then read from the returned descriptor. This method is one way either
you read or write, but it is less code than fork.


Neither popen, nor fork is a standard C or C++ function. They are POSIX
functions, off-topic here. But that is not the point: since they aren't C
and C++ functions it is nice to mention that fact once you post them into a
C++ newsgroup.

--
WW aka Attila
Jul 19 '05 #4
budgie wrote:
Hi there,

I'm using the system() function to call a program but would like to
get the result of this operation.

system returns an int depending on weather the command was executed
successfully of not.

How can I get a string -- or array of strings with the output of the
camming line application instead?

Thanks

Karl

maybe
char * d << system("yukk.exe");
might work
but then it probably will not
but you could make it work with:
my_string x << system("yukk.exe");
but probably not, because standard out is standard out

Jul 19 '05 #5

"klaas" <ja*@zonnet.ru> wrote in message news:UKihb.11381$732.1216351@zonnet-reader-1...
maybe
char * d << system("yukk.exe");
might work
but then it probably will not
but you could make it work with:
my_string x << system("yukk.exe");
but probably not, because standard out is standard out


System doesn't return strings. System returns a single int.
If the argument is other than a null pointer, the value of this
single int is implementation-defined.

It's not a bunch of strings reflecting the output of the command
invoked in any case.

You will have to do this in a system dependent fashion. If you
are on a UNIX/POSIX system, try popen.
Jul 19 '05 #6

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

Similar topics

7
by: roger | last post by:
I'm having difficulties invoking a user defined table function, when passing to it a parameter that is the result of another user defined function. My functions are defined like so: drop...
2
by: swhite76 | last post by:
I have a section of code that adds some double values and gives an incorrect result. This occurs with data that isn't really waht I would call high precision. An example is the following code...
3
by: Hewit | last post by:
I have a stored procedure which returns records and output parameters(SQL2K). How to call this stored procedure using ADO.Net so that I can use both results in my application. I have .Net...
1
by: Dave Brown | last post by:
I am attempting to post to a url (https://FakeURL/logon.asp) using the HttpWebRequest class. The response for a succesful post will contain the html for the logon user's default page. We've...
62
by: ashu | last post by:
hi look at this code include <stdio.h> int main(void) { int i,j=2; i=j++ * ++j * j++; printf("%d %d",i,j); return 0;
5
by: Lee | last post by:
(I also posted this query in Microsoft.Public.DotNet.Framework yesterday, but since I have received no responses, I am posting it here too.) Using Windows XP with all updates applied and Visual...
0
by: prad | last post by:
Hi, Following java code returns 24 result sets.It counts number of rows in the first result set correctly.But doesnt count rows from next result set. When I debugged the code I found out that...
1
by: Maxwell2006 | last post by:
Hi, I am working with strongly typed datatables. What is the most efficient way to build a new DataTAble based on the result of DataTable.Select? At this point I use a foreach loop to do the...
4
by: kwatch | last post by:
Hi, I have a question about os.times(). os.times() returns a tuple containing user time and system time, but it is not matched to the result of 'time' command. For example, os.times() reports...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...

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.