I need my java program to exec an external .exe file, but the problem
is that this program being exec()'ed prompts the user for two pieces
of information. I am trying to get my java program to automatically
send data to the other program but for some reason the child hangs.
The first piece of info prompted for is an integer, and the second
prompt asks for a floating number. I am trying to send the program
"3\n" to satisfy the first prompt and ".9982\n" to satisfy the second
prompt. I am using this on windows XP with jsdk 1.4. The whole code
is:
import java.io.*;
class test {
public static void main(String[] args) throws Exception {
String numImages;
String density;
numImages = "3\n";
density = "0.9982\n";
System.out.prin tln("creating child");
try {
Process p = Runtime.getRunt ime().exec("ape nd.exe");
OutputStream out = p.getOutputStre am();
out.write(numIm ages.getBytes() );
out.write(densi ty.getBytes());
p.getOutputStre am().close();
p.waitFor();
System.out.prin tln("child finished");
} catch (IOException e) {
}
}
} 1 3586 ch************* @yahoo.com (Chad) wrote in message news:<bc******* *************** ****@posting.go ogle.com>... I need my java program to exec an external .exe file, but the problem is that this program being exec()'ed prompts the user for two pieces of information. I am trying to get my java program to automatically send data to the other program but for some reason the child hangs. The first piece of info prompted for is an integer, and the second prompt asks for a floating number. I am trying to send the program "3\n" to satisfy the first prompt and ".9982\n" to satisfy the second prompt. I am using this on windows XP with jsdk 1.4. The whole code is:
import java.io.*;
class test {
public static void main(String[] args) throws Exception { String numImages; String density; numImages = "3\n"; density = "0.9982\n";
System.out.prin tln("creating child");
try {
Process p = Runtime.getRunt ime().exec("ape nd.exe");
OutputStream out = p.getOutputStre am();
out.write(numIm ages.getBytes() ); out.write(densi ty.getBytes());
p.getOutputStre am().close(); p.waitFor();
System.out.prin tln("child finished");
} catch (IOException e) { }
} }
If your append.exe program get the input from stdin, your code should
work. However, since your current code doesn't read prompts and
doesn't do waitFor(), it should fail. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alan Walkington |
last post by:
Folks:
How can I get an /exec'ed/ process to run in the background on an XP box?
I have a monitor-like process which I am starting as
'exec("something.exe");' and, of course the exec function blocks until
something.exe terminates. Just what I /don't/ want. (Wouldn't an & be
nice here! Sigh)
I need something.exe to disconnect and run in the background while I
|
by: Irmen de Jong |
last post by:
Hello,
I don't understand why the following doesn't work.
What I want to do is dynamically import some generated
Python code and I'm doing this using compile and exec'ing
it in the dict of a new empty module object.
That works okay, but as soon as the generated code
tries do perform certain imports, it fails!
Certain other imports succeed. Consider this example code:
|
by: It's me |
last post by:
I am new to the Python language.
How do I do something like this:
I know that
a = 3
y = "a"
print eval(y)
|
by: Thomas Covello |
last post by:
Hello,
When the following perl script is executed:
#!/usr/bin/env perl
use strict;
use diagnostics;
use warnings;
# Header bytes for different zip formats
my $GZIP_HEADER = "\x1f\x8b\x08\x08";
|
by: a |
last post by:
Hi,
The php script that processes user input from a form, starts a new process
using exec. In my case, the process may contain arbitrary, user defined
functionality. How do I ensure that that process doesn't do any harm? Is
there a way to define a sort of sandbox that the process can run in, so it
won't be able to access any unauthorized resources, or do some other damage
to the server?
I am running PHP 5.1.2 on Apache 2, on Win XP...
| |
by: jeremyfee |
last post by:
The spawn* and exec* functions appear to escape asterisks, I'm
guessing all shell characters too, before the spawn/exec'ed process
sees them. Is there a way around this?
Not sure if this is a bug or a "feature".
user$ touch test.txt
user$ ls -l *
-rw-r--r-- 1 user user 0 Apr 18 18:30 test.txt
user$ ls -l \*
|
by: Adam Atlas |
last post by:
Is it possible to make more traceback information available for
exceptions code dynamically run via `exec`? Normally it just says
things like "File '<string>', line 3, in ?", which is not very
helpful. I'm looking for a way for it to show the line of source code
below it, like it would for an exception in a physical file. Is this
possible?
|
by: exscape |
last post by:
Hey everyone,
I'm writing a tiny web server, mostly to learn - security and such is
a non-issue, but learning how to make things secure is of course nice
too. To be clear - I will most likely not even use it myself.
In any case. I've added some minor scripting support, so that you can
write dynamic pages in Python. To do this, I use execfile(), and pass
the script a dictionary with some basic variables. The script then
sets a "ret"...
|
by: eliben |
last post by:
Hello,
In a Python program I'm writing I need to dynamically generate
functions and store them in a dict. eval() can't work for me
because a function definition is a statement and not an expression, so
I'm using exec. At the moment I came up with the following to make it
work:
def build_func(args):
code """def foo(...)..."""
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |