Execute a script in a Linux machine from a Java application

Hi,
I am trying to execute a script in a Linux machine from a Java application on a Windows environment. My code is
commande="rsh 185.30.30.30 -l goku /newfolder/bench/bin/Agent start ";
try{
Process process = Runtime.getRuntime().exec(commande);
catch(Throwable t){}
It works fine but the script takes too much time to start (almost 3 minutes). My question is there exists anther way to execute the script, another command? I have already tried ssh but windows doesn�t recognize it
If somebody has any idea please let me know...
Thanks

The script starts and stops a process (Agent) so it doesn�t take too much time to execute itself. It is when I execute the script from my java program that i must wait to watch my process running in my Linux server.

Similar Messages

  • Execute a script on a remote machine - possible?

    I am sorry if this sounds silly - what I would like to know is if its possible for a java program executing on one machine to execute a shell script that resides on another machine.
    That script in turn invokes a java program which does some other stuff.
    I know the way to do it would be to eliminate the script altogether and have the java program on the other box listen on a port and have it accept connections from the host machine. But a client is insistent he doesnt want it that way and I am not even sure if its possible to do as he says. I am aware that I can use the Runtime and Process classes to invoke a script on the same machine that the java application executes on, but is it possible to invoke a script on another machine?
    Thanks,
    Ram.

    If they're running the server on a *NIX box, you might check into inetd or xinetd - this is basically a proxy that listens on a certain port, starts a process running when it gets a request on that port, hands the request to that process, and then the process exits while xinetd waits for the next request.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Can I build an application for a linux machine from a windows machine?

    Is it possible, with LV2012, to build an application for a target other than the the machine type that I am working on?
    meaning, can I build an application to run on a linux machine from my development machine, which runs on windows?
    alternatively, can I build an applications to run (natively, no WOW) on a 32-bit OS from a development machine that is a 64-bit OS and 64-bit labview?
    Or does LV only build for similar targets as the development platform, and I would need to move the source code to another development machine to generate code for a different type of target machine?
    Thank you!
    Solved!
    Go to Solution.

    You can only do a build for the OS that you have a license for and for the OS bitness that you are using. In other words, you need LabVIEW for Linux or LabVIEW for Mac to build exe's for them and you need LabVIEW Windows 64-bit to build a 64 bit exe. It does require moving the source code to the other development systems.

  • Writing into a file in clients' machine from a jsp application

    is it possible to write some data fetched from database into a .CSV file on the clients machine from an JSP application?
    signed applets is one possibility , any other possibilities are there?
    thanks
    Mohammed Rafeeq([email protected])

    * @(#)ExcelServlet.java
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    import java.util.*;
    import java.sql.*;
    * @author M.Rajendra
    public class ExcelServlet extends HttpServlet {
         public void init(ServletConfig config)throws ServletException{
              super.init(config);
         } // end of init method
         public void doGet(HttpServletRequest req, HttpServletResponse res)
                                                 throws ServletException,IOException     {
              doPost(req,res);
         } // end of doGet method
         public void doPost(HttpServletRequest req,HttpServletResponse res)
                                                 throws ServletException,IOException     {
              HttpSession session = req.getSession(true); // session is already created at loginscreen
              OutputStream oout = res.getOutputStream();
              res.setHeader("Content-disposition","filename=excel.csv");
                   //res.setContentType("application/octet-stream");
                   FileInputStream fis = new FileInputStream("D:\\JRun3.1\\servers\\default\\default-app\\WEB-INF\\classes\\test.csv");
                   //here i am reading a csv file, we can output whatever format and set filename of ours
                   byte[] buf = new byte[1024];     //get from statics
                   int bytesRead = 0;
                   while((bytesRead = fis.read(buf)) != -1){
                        oout.write(buf,0,bytesRead);
                   oout.close();
                   fis.close();
         }//end of doPost method
         public void destroy()     {
         }// end of destroy
    } //end of ExcelServlet class

  • Executing any other applications from a java application

    how can i execute or invoke other applications on the pc
    from a java application?

    Runtime.getRuntime().exec("dir");

  • Can we execute DOS Commands from a Java Application

    I just want to know whether we can execute DOS Commands from a Java Application.
    Thanks.

    hi,
    try this:
    Runtime.getRuntime().exec("cmd /c start abc.bat");
    andi

  • Manipulate Indesign cliente from a Java Application

    Hello, I need to manipulate Indesign client(open/close documents, create menus, tables, set colors etc... ) but I need to do that from a Java application. Is it possible? I was searching on google about it, even in Adobe's site, but the only way I found was thought Javascript, VbScript or AppleScript.
    Thanks in advance!
    Rafael

    I can control inDesign from Python or shell scripts on osx via `osascript` This is roughly how it works.
    My 'master' program runs shell command `osascript -e "tell Indesign blahblah end tell" /path/to/temporary.jsx`  
    `osascript` tells Indesign to execute "/path/to/temporary.jsx" as javascript
    If all goes well, the value of last expression  in .jsx is returned by `osascript` (serialised JSON works great for this)
    Sorry I'm vague on real life code, but this is my home machine so it's not in my reach.
    I realise it's an ugly hack. Main cons follow:
    quotes have to be escaped couple of times so the result is messy and prone to errors (luckily it's one-off code that sits hidden behind main interface)
    debugging this chain is nightmare (especially with my nigh-zero knowledge of applescript)
    so far it's mac only (I suspect same thing can be achieved on Windows machine with VBS)
    one cannot avoid writing lots of temporary files to the system. (luckily for me, it's only deployed on machines under my control, so the temp files are written to /tmp which is mounted on ramdisk)
    The only pro I can think of is that it works. Whole comlexicity is wrapped in one python module, which I only see when squashing the bugs.
    Marcel

  • Running a dos command from a java application

    hello,
    I'm trying to execute a batch file from a java application. I tried with:
    try
    Process proc=Runtime.getRuntime().exec("fop -fo "+iXmlFoFile+" -
    svg "+SvgFileName);
    }catch (IOException e){System.err.println("Error in conversion of
                               the Xml FO file into Svg file: "+e);}
    and with:
    try
    Process proc=Runtime.getRuntime().exec("cmd ./c fop
    -fo "+iXmlFoFile+" -svg "+SvgFileName);
    }catch (IOException e){System.err.println("Error in conversion of
                the Xml FO file into Svg file: "+e);}
    but i have a IOException: CreateProcess: .... error=2
    When I try these line to launch a .exe file it works but not with a .bat file.
    I also tried:
    String execstr = "fop -fo "+iXmlFoFile+" -svg "+SvgFileName;
    String [] commandArray = { execstr };
    try {
    Runtime.getRuntime().exec(commandArray);
    } // end try
    catch ( Exception e ) {
    System.out.println( e.getMessage() );
    e.printStackTrace();
    }// end catch
    but i got the same exception in java.lang.Win32Process.create
    What did i do wrong?

    Your execution string is a bit more that I want to figure out, but here are a couple ideas:
    Is the working directory of any importance? If so you'll need to set that when you do your exec()
    I think I remember reading something about batch files that couldn't be kicked off via this method. Perhaps you need to execute the string "start mybatchfile.bat". Seems like you need to do something like that to get a command interpreter to run your batch file.

  • Launching TextEdit on a Mac from a Java application

    I am having a problem launching textedit from a Java application. It was working a week ago on a fresh iMac, but since then I have installed Lightroom, Photoshop, the Studio MX suite stuff, and now the textedit program does not start from my Java app. This is the code that I am using in my application to launch textedit:
    String command = "open -e \""+filename.getAbsolutePath()+"\"";
    Runtime rt = Runtime.getRuntime();
    rt.exec(command);I've also tried it this way:
    String command = "open -e \""+filename.getAbsolutePath()+"\"";
    Process child = Runtime.getRuntime ().exec (command);I've printed the command to execute out on the console and it appeared like this:
    open -ef "\Users\user\Desktop\filename.txt"But it doesn't open textedit. The funny thing is, if I copy and paste that open command into the Terminal, it will open the file in TextEdit. Why won't it work in my Java app anymore, but still work through the terminal? I don't get any errors in the console, it just doesn't open TextEdit anymore. Is there a setting somewhere that might have been changed that let me start TextEdit from a Java app. I checked and TextEdit is still my default program for opening text files, which I guess makes since why it works from the Terminal, but I don't get why it doesn't start TextEdit from my Java app.
    Some of this might just be a Mac issue, I'm new to that system. But the code I'm using used to work. I guess maybe I'm looking for another (better) way of opening TextEdit on the Mac from Java.
    I'm using Java 1.5.0_07. Thanks.

    Try specifying an absolute path for open (/usr/bin/open ?).

  • Displaying a URL from a Java application

    Hi,
    I recently implemented a test Java application based on Steven Spencer's Java Tip 66: "Control browsers from your Java application" (http://www.javaworld.com/javaworld/javatips/jw-javatip66.html). Spencer's example tests for the current operating system, sets some constants based on the OS that it finds, and then calls the Runtime.getRuntime( ).exec( ) method. During the call, you can pass either a file:// or http:// URL. I can get the example to work perfectly given a file:// URL but have limited success supplying the http:// URL. When I supply a specific http:// URL such as "http://someserver/somedir/testfile.htm" the browser returns a "Cannot open URL" error. However, if I supply a URL that does not resolve to a specific HTML file, such as "http://someserver/somedir", and the directory has either a "index.htm" or "index.html" file, the application works fine. I would like to be able to pass an http:// URL that resolves to a specific HTML file. I am trying to implement context-sensitive help from within a Java application. I am testing this on a machine running Windows 2000 and using Microsoft's IE 5.x browser. Any help would be appreciated.
    Thanks,
    Scott Rifenbark

    The browser doesn't know that it was started by this Java code, you know. So you are asking why your browser (Internet Explorer) doesn't let you get at specific files. The answer is, that isn't how the Internet works. A URL is a "Uniform Resource Locator" (or something a lot like that). It locates a resource on the Internet. This resource may or may not be a file, but as the client you have no way of knowing whether what you get in response to that is a file on the server or whether it has been generated by some CGI program there.
    When you send an http:// URL to a web server, it looks at what you have sent and goes through its configuration files. Using this it translates that URL into either a file on the server (which it returns to you) or a program which it calls to return data to you. If it was a file, its local name on the server doesn't have to be related in any way to the contents of the URL.
    It sounds like you are planning to be the one setting up those files on the server, though. If that's the case, you have to configure the server appropriately for your needs.

  • How can i call a jasper report from a java Application

    Hi,
    i am chiranjit , currently i working in a web based ERP project, in this project as a report building tool we are using JasperReport wih eclipse plugin . in eclipse report's are generating very well but i am unable to call that report from a java application because i have no idea about the How to call a Jasper Report from a Java Application . so please send me the necessary class names, jar files names and programe code as early as possible.
    Chiranjit

    Ahh, kind of a duplicate thread:
    http://forums.java.sun.com/thread.jspa?threadID=631642
    @OP. You could have clarified your original post and the relationship of your question to java. You did not need a new thread.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can i call a VB6 project from my java application using JNI

    hi
    can anyone tell me the procedure of calling a VB6 project from any java application using JNI
    if anyone does know then tell me the detail procedure of doing that. I know that i have to create a dll of that VB6 project then to call it from the java application.
    if anyone know that procedure of creating dll file of an existing VB6 project please reply
    please if anyone know then let me know

    Ahh, kind of a duplicate thread:
    http://forums.java.sun.com/thread.jspa?threadID=631642
    @OP. You could have clarified your original post and the relationship of your question to java. You did not need a new thread.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Calling a web service from a Java application

    Does anyone have sample code showing how to call a web service over from a Java application? I'm deploy to HP-UX and seeking out the most standard and reliable approach.
    Thank you in advance.

    Keith,
    Download JWSDP 1.2, look at the tutorial for JAXRPC, especially
    the client portion.

  • How do i Hyperlink to a web page from a java application?

    How do i Hyperlink to a web page from a java application using internet explorer as my default web browser?

    It's very simple.You can start any Application with the class Runtime. The command is an array consisting of the path of .exe and the file to be open.
    String [] cmd={path of IE+Filename.exe,"URL of your website"}
    try
    Runtime.getRuntime().exec(cmd);
    catch (Exception e)
    System.err.println(e.toString());
    }

  • How to call pdf forms developed in ABAP from WD Java application?

    Hi
    I have a web dynpro ABAP application that that is responsible for generating PDF forms for all other applications (WD ABAP and WD Java).
    How can I call the pdf forms generated by the WD ABAP application from WD Java application in a separate window?
    These forms are to be called on click of a "Print" button. Also, these forms are non interactive.
    Kindly let me know if you need any other information.
    Regards
    Vineet Vikram
    Edited by: vineet vikram on Jun 24, 2009 7:28 AM

    in addtion to Nikhil's response. you can write following code on action of print button:
        IWDWindow window = wdComponentAPI.
            getWindowManager().createExternalWindow(
                  "<ABAP Application URL>",
                  "<Title for window>",
                  false);
       window.open();
    to Close the application, you can use the window close or u can fire an event to close current window.
    Abhinav

Maybe you are looking for

  • My iPod has had everything wrong with it! Can anybody please help?PLEASE!!!

    Hey All Please help me with my ipod. Ive been trying for so long to get it working( More than 4 Months) but with no luck. The problems started when my friend asked me to plug his ipod into my computer to get my songs because his ipod wouldnt load son

  • Is it possible to recover songs from ITunes account?

    My old computer was stolen, along with lots of iTunes songs I had purchased. I now have a new computer and was told that I could get all the songs I've purchased restored...how do I do that?

  • Can't get AS3 KeyboardEvent to work

    When I use the code below to capture a KeyBoard event I get the following error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Racer$iinit() at MyMain$iinit() Can anyone tell me why? -----Code------ package

  • MICROSOFT VISUAL C++ RUNTIME ERROR

    HI, PLEASE I WOULD NEED HELP AS REGARDS THE ABOVE SUBJECT MATTER. THE ERROR BEING DISPLAYED IS LINKED TO C:\WINDOWS\EXPLORER.EXE I WOULD LIKE TO KNOW HOW TO CORRECT THIS ERROR ON WINDOWS 8 OPERATING SYSTEM THANKS

  • ODI Packages execution based on condition

    Hi, We have clear the data using calc scripts and then load data into Hyperion using ODI packages. Currently i have one Package (Package1) to be executed on WD2 & WD3. I have created an interface which will execute the script. Here calc scripts are d