Exec a unix process with java
Hi all
I am trying to write a statistic pgm in java about process queues in tmsdmin.
The code segment looks like below.
Process proc = Runtime.getRuntime().exec("tmadmin");
This works perfectly but my question is how can I exec pq ? pq is a command in tmadmin itself??
I will be very thankful for any help regarding this Problem.
chkmja
Why not try to exec the command with the redirections ?
For example:
try {
// Create input file
String inputfilename = "inputfile.txt";
BufferedWriter bw = new BufferedWriter(new FileWriter(inputfilename));
bw.write("pq"); // and so on...
bw.newLine();
bw.close();
// Create redirected command
String exec_cmd = "tmadmin < " + inputfilename;
// Run command
Process proc = Runtime.getRuntime().exec(exec_cmd);
catch(Exception e) {
e.printStackTrace();
}Hope this helped,
Regards.
Similar Messages
-
On Unix Clinet with Java 1.4.1 plug-in, text boxes are not working
On Unix Client with Java 1.4.1 plug-in version, text box is not responsive (I am not able to enter anything).
But If load the same applet on the same client by upgrading the plug-in to 1.4.2, it works. Is this a known bug in Java plug-in 1.4.1?
ThanksMight be related...
http://developer.java.sun.com/developer/bugParade/bugs/4806274.html -
Invoking Unix command with java stored procedure
Hi,
I have a perfectly working environment and now I am trying to replicate the same in another server. I have a java stored procedure which invokes the Unix command using java Runtime.exec() in my code named "run". I am sure that the code is called and the java class run is resolved in oracle as I could see that in dba_java_resolvers dictionary. But I am not sure whether the function in java is called or whether a exception is thrown. how to identify this? Could there be any thing to do with settings in oracle side? please help me.
Thanks in advance,
MaruthaHi,
Do you get any output while running the code?
I'm testing similar solution and if there are any errors or Oracle can't execute the program due to permissions or other issues the error information will be displayed. Also in the Java class itself you need to catch exceptions and print stack trace to standard output.
declare
x number;
begin
dbms_output.enable(1000000);
dbms_java.set_output(1000000);
x:=system_command.run_command('testconnect.sh');
dbms_output.put_line('Returned value='||x);
exception
when others then dbms_output.put_line('Sql error='||substr(sqlerrm,1,250));
end;
<system_command.run_command> - replace with a call to your java stored procedure. -
Error while invoking Livecycle process with Java
Hi,
I am trying to invoke a short lived process using java code. But when i try doing that i get the following error
cannot access class com.adobe.idp.dsc.clientsdk.ServiceClient; class file has wrong version 49.0, should be 45.3 or 46.0 or 47.0 or 48.0.
I am using the following versions:
Adobe Livecycle: 9.0
java version "1.5.0_03"
JDeveloper: 9.0.5.2
Can some one please suggest the appropriate action i need to take so that i can compile the code.
Thanks in advanceIf you are invoking LiveCycle ES2 on JBoss compile with JDK 1.6 and run against JRE 6.
Steve -
Connection to a Unix-Server with Java
Hi!
I've got a little problem! I must write a java programm that connects to a unix-server! The programm should connect to the server and writes a command like "ls"! How can I do this? Can someone help me?
Thanks Flyer2004Hi,
something to help you with your assignment.
The code below will connect to a server on a port.
public void run() {
try
Socket socket = new Socket( "abc.com" , 13312 );
System.out.println( "Connected to the server" );
PrintWriter pw = new PrintWriter( socket.getOutputStream(), true );
BufferedReader stdIn = new BufferedReader( new InputStreamReader(System.in) );
BufferedReader in = new BufferedReader( new InputStreamReader( socket.getInputStream() ) );
String userInput;
while ( (userInput = stdIn.readLine()) != null ) {
pw.println( userInput );
System.out.println("echo: " + in.readLine() );
catch ( Exception ex )
ex.printStackTrace();
you can use this code to connect to a port.
now comes the server part.....
ServerSocket serverSocket = new ServerSocket( 7777 );
FileInputStream fis = new FileInputStream( "test.dat" );
Socket socket = serverSocket.accept();
OutputStream os = socket.getOutputStream();
byte[] buffer = new byte[1024];
int bytes = 0 ;
int i = 0 ;
while( ( bytes = fis.read( buffer ) ) != -1 ) {
os.write( buffer, 0, bytes );
os.flush();
i++ ;
System.out.println( "bytes sent : " + i + " KB " ) ;
os.close();
fis.close();
The code above post's the file back...
in your case you want the output of your command so use "Runtime.runexec" and run your command on the server..
use the above code and replace the file downloading part with your code....
send back the output of the same to the client...
just in case ...
if you want to do any random commands... you need to let your server knwo that and the code for that needs to be persent on the system.
by the way this is pure vanilla and it needs to be modified a lot.
Regards,
myraid -
XML Processing with Java (Elliotte Rusty Harold) PDF
Anyone knows where can i get this book on PDF format??
I know Elliotte offers this book on-line on his page, but I would like to get it on pdf better than html.
If anyone can help I would appreciate it very much.
Thanks in advance.
Ivan.Hi
I found this at metalink [Note:390968.1].. hope it helps =)
Symptoms: When attempting to run an XML Publisher concurrent program the following error occurs:
ERROR: Warning!!! Got out of memory exception, retrying with scalable option..
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
Oracle.apps.xdo.oa.cp.JCP4XDODataEngine
Program exited with status 1
Solution: To implement the solution, please execute the following steps:
1. Login select the responsibility: System Administrator.
2. Navigate to Concurrent > Program > Define.
3. Query for concurrent program that is receiving the error.
4. In the 'Options' field please enter -Xmx512M.
5. Save the change and retest the issue.
6. If the report still fails with the option set to -Xmx512M change the value to -Xmx1024M, save and try again
7. Migrate the solution as appropriate to other environments. -
Sending unix command with java
Hi! I need to terminate program from server with "Ctrl+x" command.
How do I send this kind of command to the server?Uh, by sending a
new String(new char[]{'\030'})? -
Unable to deploy BPEL with java embedding
Hi ,
I have created a simple BPEL Process with java embedding for over ruling the BPELinstance name in it .But I am unable to deploy as Jdeveloper is showing that jar files should be included in the classpath ,though I had included in the class path. Below are my code and the error which is shown by the Jdeveloper.
<bpelx:exec name="JavaSetTitle" language="java" version="1.4">
<![CDATA[
Element inVarElem = (Element)getVariableData("inputVariable"
, "payload"
, "/client:HelloWorldProcessRequest/client:input");
try
String inputdata = inVarElemOrpsId.getNodeValue();
String title = "HelloWorld " + inputdata;
setTitle(title);
addAuditTrailEntry("New Title is: >" + title + "<");
catch (Exception ex)
ex.printStackTrace();
}]]>
</bpelx:exec>
Error:
Error: Java compilation failed.
Failed to compile file(s) "TestBPEL.bpel".
Exception reported is: TestBPEL.bpel:64: Class bpel.testbpel.Element not found.
Element inVarElem = (Element)getVariableData("inputVariable"
^
TestBPEL.bpel:64: Class bpel.testbpel.Element not found.
Element inVarElem = (Element)getVariableData("inputVariable"
^
TestBPEL.bpel:69: Undefined variable or class name: inVarElemOrpsId
String inputdata = inVarElemOrpsId.getNodeValue();
^
3 errors
Please verify that file TestBPEL.bpel is valid java file or if all required libraries are included in your classpath.
classpath: ..\..\..\classes;..\..\ide\lib\javax-ide.jar;..\..\ide\lib\javatools.jar;..\..\ide\lib\ide.jar;..\..\jlib\jewt4.jar;..\..\jlib\share.jar;..\..\jlib\help4.jar;..\..\jlib\inspect4.jar;..\..\lib\xmlparserv2.jar;..\..\jdbc\lib\orai18n.jar;..\lib\jdev-ep.jar;..\..\jdk\lib\tools.jar;..\..\jdk\lib\dt.jar;..\lib\ext\jaxen-1.1-beta-4.jar;..\extensions\oracle.ide.10.1.3.jar;..\..\jlib\ojmisc.jar;..\extensions\oracle.jdeveloper.10.1.3.jar;..\lib\jdev.jar;..\lib\ojc.jar;..\..\jlib\regexp.jar;..\..\ant\lib\ant.jar;..\..\ant\lib\ant-..................Or try removing the client: from your original code
<bpelx:exec name="JavaSetTitle" language="java" version="1.4">
<![CDATA[
Element inVarElem = (Element)getVariableData("inputVariable"
, "payload"
, "/HelloWorldProcessRequest/input");
try
String inputdata = inVarElemOrpsId.getNodeValue();
String title = "HelloWorld " + inputdata;
setTitle(title);
addAuditTrailEntry("New Title is: >" + title + "<");
catch (Exception ex)
ex.printStackTrace();
}]]>
</bpelx:exec>cheers
James -
Hi all
Could anybody tell me how can I exec an sql proc with Java?
Thank you very much
Regards
chkmja
My Java code and SQL proc look like below.
Java code
m_connection.createStatement().execute("exec MSG_SNAPSHOT()");
sql Proc
CREATE OR REPLACE PROCEDURE MSG_SNAPSHOT AS
BEGIN
EXECUTE IMMEDIATE 'TRUNCATE TABLE REVISION_MESSAGE';
INSERT INTO REVISION_MESSAGE (PK_ID, MSGSTATE, SCHEDSTATE, EXTERN_ID, OBJECT_NAME, PROCESS_AT)
SELECT msg.PK_ID, msg.MSGSTATE, msg.SCHEDSTATE, msg.EXTERN_ID, msg.OBJECT_NAME, msg.PROCESS_AT
FROM MESSAGE partition (non_final) msg WHERE msg.SCHEDSTATE <> -1;
END;
Here my problem is I get --->
java.sql.SQLException: ORA-00900: invalid SQL statementJust a quick check under java.sql.Connection found:
prepareCall
public CallableStatement prepareCall(String sql)
throws SQLException
Creates a CallableStatement object for calling database stored procedures.
Isn't this what you should be using and not createStatement() ? -
How can I develop co-broswing on Windows platform with java language?
How can I develop co-broswing on Windows platform with java language?
The function will be realized
Now I want to develop a co-broswing system with java language on Windows platform.That is to say I will develop
a application run on client to track the present browser.Wheh the URL address of your present if changed(for example
when you click a link or submit a form),the application will capture the new URL address and send it to the other
client that make co-browsing connect with you.The browser on the other client side will catch the new URL and refesh
the page to show the page.
The question I fall across and want to ask you
(1)How to watch system process with java on the Windows platform?Because I want to get the process information of
the present broswer,and then get the URL address of the present broswer.
(2)Develop an application to watch the URL address of the present broswer continuance,If the URL address is changed,
then send the new URL address to the client on the other side,let his broswer to show the new page using the new URL.Paulc, A proxy server is not the right thing.
What our man here is looking for is a solution for two
users to kind of surf the net "in tandem" - when one
user navigates to a different web page, so does the
other user,
These are typically used in call center applications
where the advisor guides a caller through , say
filling in an insurance form or pointing him to the
right product specification pages.
Xing, why are you using Java for this ? You need
something that has better windows integration. If you
look on MSDN.microsoft.com and search for "explorer
bar" you will find solutions to the questions that you
raised.
There are also commercial products on the market that
already do this kind of stuff. there is one from
www.genesyslabs.com which is considered to be the best
of breed.
It is difficult or almost impossible to do this in
Java for a commercial application.
If you are developing this as an academic exercise,
give it a try. Post your email address here, and I
will contact and help you out if you like.my e-mail is below ,I want to contact you and need all of your help.
[email protected] -
Problems with Runtime.exec() and certain Unix processes
Certain Unix processes don't behave correctly when run from Java using Runtime.exec(). This can be seen by running /bin/sh and trying to interact with it interactively. The issue appears to be that /bin/sh (and many other Unix tools) are checking the file handles on the spawned process to see if they are associated with a TTY.
Is there any way to associate a process spawned by Runtime.exec() with a terminal or alternatively, is there a JNI library available that would setup the process correctly and still provide access to the input and output streams?
Our objective is to have the flexibility of expect in being able to run and interact with spawned processes. A bug was opened at one point but closed back in 1997 as being a fault in the spawned process, not Java.
Bug ID: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4058689#include <stdio.h>
void doit() {
int c;
while((c=getc(stdin)) != EOF) {
printf("%c",c);
int main() {
freopen("/dev/tty", "r", stdin);
doit();
}This program reopens its standard input against /dev/tty and catenates it to stdout. And voila, it takes its standard input from the terminal, even though it was started with stdin against /dev/null..
$ gcc b.c -o b
$./b < /dev/null
buon giorno
buon giorno -
Spawn Unix Process in same shell with Java
Hello,
Does anyone know how to use java to prompt the user for input, execute their command, wait for the command to finish and then prompt them again.
I am able to prompt the user for input, but if they type 'vi filename' and I execute it, the user never sees the vi screen to edit the file. I would like to be able to allow other programs like 'vi' to use the same command line terminal that the user is currently in with java. Currently executing any command is fine, and I can read the process i/o. The only problem is when a program like 'vi' needs the terminal. Does java prevent that from happening when spawning a process?
Thanks,
RickShould this be command line based? There are several graphical java terminal emulators, here's an open source one for instance:
http://javassh.org/wiki-view?oid=5F8180808080808080808080808086neotis -
Kill "runtime.getruntime().exec"-generated processes with control-c?
Hi there,
In my java program I create 2 processes with "runtime.getruntime().exec", but when I stop my java program pressing control-c these 2 processes remains running and I have to kill them using linux command "kill".
How can I program my code in order to kill these 2 processes when stopping my java program with control-c?
I tried next but it didn't work for me:
try {
final Process proc = Runtime.getRuntime().exec ( "java ControlCProblemDemo" );
Runtime.getRuntime().addShutdownHook(
new Thread(){
public void run(){
proc.destroy();
while ( true );
} catch( IOException ioe ) {
System.err.println( ioe );
}Thank you very much in advance.
Josuéso are you saying proc.destroy() does nothing?
are you sure it's getting executed?
is there an error?
too little info here -
Issue about Invoking a BPEL Process with the Generic Java API
I Invoking a BPEL Process with the Generic Java API and apache axis or axis2
it turn up a error as follow:
org.apache.axis2.AxisFault: ORABPEL-08021
Cannot find partner wsdl.
parnterLink "BPELProcess1" is not found in process "BPELProcess1" (revision "v2008_11_17__38943").
Please check the deployment descriptor of the process to find the correct partnerLink name.
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:512)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:370)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:548)
at org.apache.axis2.client.ServiceClient.sendReceive(ServiceClient.java:528)
at wf.Test_axis2_callws.main(Test_axis2_callws.java:41)
i can't solve it !
what's problem ???
anyone use java code to invoke bpel process successfully..can show me some example?
thanks
chanHi,
Check below link may help you solve your problem.
http://www.activevos.com/cec/samples/content/sample-invoke/doc/index.html
Regards -
File processing failed with java.lang.StringIndexOutOfBoundsException:
Hi
I´m reading and sending files to an FTP server using SAP PI. I use file content conversion.
Everything has been working fine for months - but now the server was changes to a new host. The only thing changed was the host/user and pass.
But sending too the server fails with this error:
File processing failed with java.lang.StringIndexOutOfBoundsException: String index out of range: -27
Any body who has a clue??
Reading files works ok. And i can transfer files to the FTP server with FileZilla without problems.In the file transfer by ftp:
2011-10-03 17:27:08 Information Transfer: "BIN" mode, size 737 bytes, encoding -.
2011-10-03 17:27:08 Error File processing failed with java.lang.StringIndexOutOfBoundsException: String index out of range: -27
2011-10-03 17:27:08 Error Adapter Framework caught exception: String index out of range: -27
2011-10-03 17:27:08 Error Delivering the message to the application using connection File_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: Error occurred while connecting to the FTP server "nnn.nn.nnn.nnn:21": java.lang.StringIndexOutOfBoundsException: String index out of range: -27.
Its on the adapter level. All mappings etc are fine. And as i write has been for months. The only thing changed are the FTP server
Maybe you are looking for
-
How to change texture backgrounds in Keynote text box
I want to know if its possible to change the texture background image of a text box, keeping the background textured but in a different color. Sequence: Create a text box Add text In the inspector select "image fill" The result is a textured backgrou
-
Importing QuickTime with all markers preserved
I'm an FCE newbie (never used iMovie) who is starting to work on converting 16 years of 8mm analog and digital tapes to dvd - starting with the early analog stuff. I have mega hours, or rather hundreds of giga-bytes, of unwanted video (baby's first d
-
SharePoint 2010 and SQL DateTime data filtering
I have a SharePoint site that is using an external content type and external list to pull information from a view in SQL. One column of the contains Date/Time information. All of the information shows up fine in the SharePoint list, but as soon as I
-
hi, i have done the necessary configuration in R.3 for sending the material idocs into xi and in the xi system i have made neccsary settings in idx1 and idx2. now when i send a idoc, in SM58 it is showing as"::000" what is the cause of this error.
-
I have an old sony Mavica MVC-CD500 is there any way I can download pictures from cd to Lion
I have an old Sony Mavica MVC-CD500 - is there any way I can download cd to imac running Lion