LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-18-2005, 07:09 PM   #1
CrazyPilot
Member
 
Registered: Jan 2004
Location: Somewhere...
Distribution: Fedora Core 4, Slackware 10.1
Posts: 61

Rep: Reputation: 15
Capturing program feedback... (not sure what to call it)


i'm working on a little project in kdevelop in c++
i need to know how to get the feedback from a system command to where i can use it. i'm not really sure what terminology i should be using here, forgive me.

what i mean is like if i ran said this:
system(/etc/rc.d/init.d/httpd start);

i need some way to get what it the program's output was in terminal, for example, if it couldn't do this for some reason like 'file not found' how could i get that file not found message and put it in, um..., a QString or something? So like i could do something like this:
feedbackBox->append(where-ever-i-get-the-feedback-from());

sorry if im unclear on what i want, i cant really help it...
any information on this subject line would be useful

thx in advance,
llama
 
Old 03-18-2005, 07:19 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
It sounds like you might find popen() useful. You use it, and then do traditional file I/O routines to read the command's output.

man popen for more details of course...

EDIT: while not strictly C++, it will still work. I don't know if there is a C++ equivalent (that would create an iostream class for instance).
 
Old 03-20-2005, 01:04 AM   #3
CrazyPilot
Member
 
Registered: Jan 2004
Location: Somewhere...
Distribution: Fedora Core 4, Slackware 10.1
Posts: 61

Original Poster
Rep: Reputation: 15
that works and returns what i want but it gives it as a const char and i need it in a QString for the widget im using to accept it. any ideas on how to convert a char into a QString???
 
Old 03-20-2005, 11:10 AM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Sorry, I can't help there. I've never done any programming with the Qt library.

I would find it hard to believe that there's no overloaded '=' operator for a QString though. Something like: (QString) = (char *) or (QString) += (char *).

If they don't exist, my impression of the Qt library just dropped a couple notches...
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call other program? Xiangbuilder Programming 11 09-11-2003 09:13 PM
first perl program --need feedback farhanali Programming 5 08-04-2003 08:23 PM
Call Other Application by one Program kiennd Programming 4 08-02-2003 01:52 AM
Capturing standard output from external program brianvdc Linux - Software 1 02-12-2003 03:20 AM
how to put a shell call in a C/C++ program? Hano Programming 8 05-19-2002 02:26 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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