Hi.
I have a strange problem ... I want to create a process and capture stdout :
...
gint std_out;
char* argv[3] = {"/opt/sun-jdk-1.4.2.08/bin/java","helloworld",NULL};
//char* argv[3] = {"/usr/bin/du","/",NULL};
g_spawn_async_with_pipes("/work/", argv, NULL,
G_SPAWN_CHILD_INHERITS_STDIN,
NULL, NULL, NULL,
NULL, &std_out,NULL,
NULL);
gio_stdout = g_io_channel_unix_new(std_out);
g_io_channel_set_flags(gio_stdout, G_IO_FLAG_NONBLOCK, NULL);
g_io_add_watch(gio_stdout, G_IO_IN, printme, (void*)user_data);
...
In the case of a "normal" program , e.g. "/usr/bin/du" or anything else,
this works fine, and I can read the programs stdout.
But using the java program i dont get anything at all... !?
helloworld.java just prints "Hello world" using System.out.println.
Can anybody tell me why i cant capture the output of a java program, and
how to fix this ?
Thanks 6 2547
Mazze wrote: Hi.
(...)
But using the java program i dont get anything at all... !? helloworld.java just prints "Hello world" using System.out.println.
Can anybody tell me why i cant capture the output of a java program, and how to fix this ?
Thanks
<OT>
Java prints to java console. This question should be answered by Java
people.
Mazze <ma***@no-spam.com> wrote: Hi.
I have a strange problem ... I want to create a process and capture stdout :
... gint std_out; char* argv[3] = {"/opt/sun-jdk-1.4.2.08/bin/java","helloworld",NULL}; //char* argv[3] = {"/usr/bin/du","/",NULL}; g_spawn_async_with_pipes("/work/", argv, NULL, G_SPAWN_CHILD_INHERITS_STDIN, NULL, NULL, NULL, NULL, &std_out,NULL, NULL);
gio_stdout = g_io_channel_unix_new(std_out); g_io_channel_set_flags(gio_stdout, G_IO_FLAG_NONBLOCK, NULL); g_io_add_watch(gio_stdout, G_IO_IN, printme, (void*)user_data); ...
In the case of a "normal" program , e.g. "/usr/bin/du" or anything else, this works fine, and I can read the programs stdout. But using the java program i dont get anything at all... !? helloworld.java just prints "Hello world" using System.out.println.
Can anybody tell me why i cant capture the output of a java program, and how to fix this ?
Since literally none of the functions your code calls is standard C,
you won't get a sensible answer in this group. You should try in a
group that deals with Unix programming or Java programming.
Best regards
--
Irrwahn Grausewitz (ir*******@freenet.de)
welcome to clc : http://www.ungerhu.com/jxh/clc.welcome.txt
clc faq-list : http://www.faqs.org/faqs/C-faq/faq/
clc frequent answers: http://benpfaff.org/writings/clc
Thank you, for answering.
Actually, I do have a "serious answer."
One thing you might want to consider is the Java Native Interface (JNI)
binding. (I don't know for sure whether this applies to your
application or not.)
JNI provides an interface between Java and the C programming
environments permitting the mixing of C and Java in a single
application.
Mazze,
what you are observing here has to do with Java (not C) and how it
handles stdio (the same problem is also encountered if you invoke
processes from within Java and try to capture their output).
best not try to address this here so suggest you take your question to
a Java group (or offline) where you can find out about flushing the
stdio ;)
hth,
ajm.
On Wed, 14 Sep 2005 11:00:16 GMT,
Zara <yo****@terra.es> wrote: Java prints to java console. This question should be answered by Java people.
Java prints to stdout just like any other program. The way to capture this
is independent of wheter the program is done in java or C. It does, however,
depend on some function not defined in the C standard.
Villy This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: newgene |
last post by:
Hi, group,
I guess it is a simple question for you, but it puzzles me for a
while.
I use a wxTextCtrl in my application for output result and any
exception msg. I know I can add new msg onto...
|
by: Tsai Li Ming |
last post by:
Dear all,
I have a problem with a redirecting stdout and stderr. I am a top level
module and has no control over the imported modules that are making
system calls such as os.system or popen2.* ....
|
by: iksrazal |
last post by:
Hi all,
I've been struggling to make this command work from Java:
/usr/bin/mysql c4 --user=root --password=mypass -e "source
/home/crissilva/c4.sql"
Works fine as shown when run from the...
|
by: Michael Gaab |
last post by:
If I redirect stdout by using freopen("afile", "w", stdout);
and then I closed stdout using, fclose(stdout), essentially I am just
closing "afile".
I have to reestablish what stdout originally...
|
by: mikem76 |
last post by:
How do I automatically redirect stdout and stderr when using os.popen2
to start a long running process. If the process prints a lot of stuff
to stdout it will eventually stop because it runs out...
|
by: danebarney |
last post by:
I'm developing a Windows CE 5.0 app using C# and I need to call a child
process and then capture its stdout into a window. The solutions I've
read online for doing this involve either using the...
|
by: Jef Driesen |
last post by:
I wrote a program that writes a large amount of information to stdout
(and stderr). When run from the commandline, this output either appears
on the console window (the default) or can be...
|
by: Neal Becker |
last post by:
Is there a simple way to use a 'with' statement to redirect stdout in a
block?
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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...
| |