473,394 Members | 1,800 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,394 software developers and data experts.

Prevent console open on popen?

Is there a way I can prevent the console from opening when I use popen or would I have to do that in the program I am opening?
Mar 9 '10 #1

✓ answered by Banfa

You may have to do some experimentation but I think you could achieve what you want using CreateProcess. But you would have to create your own pipe for stdin/stdout first.

6 3746
For which purpose you want to do this things, if I know I can tell the better solution for you
Mar 9 '10 #2
A PHP viewer type deal. Not really to sure how to explain it but basically:
We type PHP source on one side of the application and hit a button then the other side displays the output.

If you need/want to see the program its here ( do note PHP must be installed and on the path ) compiled on windows.

http://97.81.192.73/PHP%20Viewer.exe

When I execute the code the PHP console opens and closes.
Mar 9 '10 #3
Banfa
9,065 Expert Mod 8TB
What command line do you use to execute the code?
What function call do you use to run that command?
Does this have to be portable or is it Windows only?
Mar 9 '10 #4
Command line is "php FILE".
Function is _popen/fputs not sure which one you meant.
Windows is fine I'm sure I can find the linux way.

Expand|Select|Wrap|Line Numbers
  1. void HPreview::updatePage( )
  2. {
  3.     FILE *fp1 = fopen( "source", "w" );
  4.     fputs( this->input->toPlainText( ).toStdString( ).c_str( ), fp1 );
  5.     fclose( fp1 );
  6.  
  7.     char buffer[1024];
  8.     QString output( "" );
  9.     long length;
  10.  
  11.     FILE *fp = _popen( "php source", "r" );
  12.  
  13.     while( fgets( buffer, sizeof( buffer ), fp ) != NULL )
  14.     {
  15.         output.append( buffer );
  16.     }
  17.  
  18.     fclose( fp );
  19.  
  20.     this->output->setHtml( output );
  21. }
  22.  
I doubt it matters but I'm using the Qt framework.
Mar 9 '10 #5
Banfa
9,065 Expert Mod 8TB
You may have to do some experimentation but I think you could achieve what you want using CreateProcess. But you would have to create your own pipe for stdin/stdout first.
Mar 10 '10 #6
Okay, thank you I'll look in to that.
Mar 10 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Will Stuyvesant | last post by:
I never used the popen or popen2 libraries but it is my understanding that they can capture the output of console based programs. Is it also possible to send keystrokes to console base programs? ...
4
by: Tian | last post by:
In Windows, I have been simply using os.system() to run command line program in python. but there will be a black console window. How can I run the program without invoking that window? i guess...
6
by: GoogleGroups | last post by:
How do I use Python to send keystrokes to a console window in Windows XP? Or perhaps there is an application that I can call to do this? Thank you for your help.
2
by: Ram | last post by:
I have a console application that brings up a dialog if invoked with no command line parameters. If I double click on my application a console window is briefly displayed before the dialog appears...
6
by: metiu | last post by:
Say I have a console app that does something in three steps: - opens a file - transfers the file through a serial port - does some elaborations and I want to build a GUI around it that, for...
1
by: Fabian Steiner | last post by:
Hello! I am currently working on an alternative for the gnome-volume-manager for multiseat systems based on HAL and DBus. Whenever the signal 'DeviceAdded' is received I would like to start a...
14
by: Rochester | last post by:
Hi, I just found out that the general open file mechanism doesn't work for named pipes (fifo). Say I wrote something like this and it simply hangs python: #!/usr/bin/python import os
14
by: nathan.shair | last post by:
Hello, I searched on Google and in this Google Group, but did not find any solution to my problem. I'm looking for a way to output stdout/stderr (from a subprocess or spawn) to screen and to...
2
by: castironpi | last post by:
Presents a console permitting inspection. Input as well as output saved in Python-readable form. Python 2.5.1 memoryconsole4.py logging to My Documents\console.log .... def f( self ): .... ...
6
by: drhilbert | last post by:
Dear all, in these days, we have found a problem we can't solve even after long long googling, so we are here asking your precious help. In our program instead of using cout to print messages...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.