LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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
 
LinkBack Search this Thread
Old 02-24-2003, 11:30 AM   #1
cratos
Member
 
Registered: Feb 2003
Posts: 95

Rep: Reputation: 15
running a console app


Can someone point me to an article/HowTo on running a console based program from a KDevelop Qt app and how to parse the output of that console program.

Thank you
 
Old 02-24-2003, 01:08 PM   #2
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
You'll want to look at various system calls (assuming you don't want this app to be portable to non-UNIX systems). Look at:

exec, execve, etc.
fork
popen (I think this is the one you want)

They all have manual pages.

Alex
 
Old 02-24-2003, 03:52 PM   #3
cratos
Member
 
Registered: Feb 2003
Posts: 95

Original Poster
Rep: Reputation: 15
Will these system calls run on a mac? j/w
 
Old 02-24-2003, 11:52 PM   #4
cratos
Member
 
Registered: Feb 2003
Posts: 95

Original Poster
Rep: Reputation: 15
All of those functions are designed for only read or write from what I understand. I need to execute a program and read the output of that program so that i can parse it. At the same time i need to issue commands to that program.

Any idea how I would do this??
 
Old 02-25-2003, 02:45 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 39,857

Rep: Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121Reputation: 1121
what language is it in? parsing text is nasty nasty nasty in c, but an absolute dream in perl....
 
Old 02-25-2003, 06:54 AM   #6
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
Quote:
All of those functions are designed for only read or write from what I understand. I need to execute a program and read the output of that program so that i can parse it.
popen executes a program and gives you a pipe which you can use to write to its standard input and read from its standard output (if you pass "r+" as the second argument), which presumably would allow you to issue commands and parse the output of the program (although as acid says, this could be nasty in C).

popen would exist in Mac OSX, I doubt it would in the earlier (non-UNIX) versions. You might find Qt/KDE has some classes/functions which let you do the same kind of thing as popen.

Alex

Last edited by llama_meme; 02-25-2003 at 07:03 AM.
 
Old 02-25-2003, 11:58 AM   #7
cratos
Member
 
Registered: Feb 2003
Posts: 95

Original Poster
Rep: Reputation: 15
I'm using Qt/KDE for this project. I will look to see if there are any existing classes/functions to do this. Otherwise i will have to reread the popen documentation.
I have been reading a lot and found a couple of other possibilities, has anyone heard of Pstreams or Dynac++?

"In the simplest case, a PStreams class is like a C++ wrapper for the POSIX.2 functions popen(3) and pclose(3), using C++ IOStreams instead of C's stdio library." http://pstreams.sourceforge.net/

Dncac++ is also a class written for multithreading.
http://www.cs.hope.edu/~dershem/reu/...c++/paper.html

Let me know what you think of these or if anyone has tried them.
 
Old 02-25-2003, 03:26 PM   #8
cratos
Member
 
Registered: Feb 2003
Posts: 95

Original Poster
Rep: Reputation: 15
Turns out both KDE and Qt have classes for this: QProcess and KProcess. I should have known they have classes for everything else.

I'll let you know how it goes.
 
Old 11-06-2003, 09:58 AM   #9
Rosenkilde
LQ Newbie
 
Registered: Nov 2003
Location: Copenhagen
Distribution: Suse Linux 8.2
Posts: 1

Rep: Reputation: 0
Help with KProcess

Hello

I'm new to programming under Linux and KDeveloper.
I hope someone can help me.

I have tried to add the kprocess.h header to a project in KDeveloper 2.1.5, but KDeveloper can not find the it. I have tried to add the include path and running configure, but to no help.

How do I add the include path to kd3 and qt3 ?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if an app is running and if it's not launch this app Coume Linux - General 3 07-28-2008 02:34 AM
Kylix console app not running on suse, but on other distros digidrag Programming 1 08-25-2005 07:53 AM
Problem running console app in X with no terminal (as a desktop shortcut) kornerr Linux - General 1 02-04-2005 12:08 AM
How to Run Win32 Console App in linux Console Lokie Linux - Software 2 08-12-2004 10:00 PM
Fullscreen console app with C or C++ scottbrown4b Programming 3 05-10-2004 06:03 PM


All times are GMT -5. The time now is 05:17 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration