Using getRuntime().exec() with Serlvet to run applications in Solaris

I am currently doing a project which requires the execution of Solaris applications through the use of Java Servlet with this Runtime method - Runtime.getRuntime.exec()
This means that if the client PC tries to access the servlet in the server PC, an application is supposed to be executed and launched on the server PC itself. Actually, the servlet part is not an issue as the main problem is the executing of applications in different platforms which is a big headache.
When I tried running this program on a Windows 2000 machine, it works perfectly fine. However, when I tried it on a Solaris machine, nothing happens. And I mean nothing... no errors, no nothing. I really don't know what's wrong.
Here's the code.
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Process process; Runtime runtime = Runtime.getRuntime();
String com= "sh /opt/home/acrobat/";
String program = request.getParameter("program");
try
process = runtime.exec(com);
catch (Exception e)
out.println(e);
It works under Windows when com = "c:\winnt\system32\notepad.exe"
When under Solaris, I have tried everything possible. For example, the launching of the application acrobat.
com = "/opt/home/acrobat"
com = "sh /opt/home/acrobat"I have also tried reading in the process and then printing it out. It doesn't work either. It only works when excuting commands like 'ls'
BufferedReader read = new BufferedReader(new InputStreamReader(process.getInputStream()));Why is it such a breeze to execute prgrams under Windows while there are so many problems under Solaris.
Can some experts please please PLEASE point out the errors and give me some advice and help to make this program work under Solaris! Please... I really need to do this!!
My email address - [email protected]
I appreciate it.
By the way, I'm coding and compiling in a Windows 2000 machine before ftp'ing the .class file to the Solaris server machine to run.

Hi!
I'm no expert, but I think I remember doing something similar a few months ago, and I think the problem was that the UNIX server does not know which shell to use. The solution was this:
Create a script that starts the program on the server, and be sure to include a first row saying:
#!/bin/ksh
to specify which shell to use (in this case Korn shell). Then call the script from Runtime.getRuntime().exec()

Similar Messages

  • How to use Adobe forms with F150 Dunning Run

    Hi,
    I want to use Adobe forms with the transaction F150 Dunning Run.
    How do I get the adobe form in customizing? I have put the FM 'FI_PRINT_DUNNING_NOTICE_PDF' in business transaction Event, BF31 - P/S modules of SAP app - 00001720, Fi-FI. But it is still not recognizing the ADOBE form.
    Any help is greatly appreciated.

    Hi,
    I am also working for calling custom adobe form instead of sapscript.
    While configuring BTE 1720, i noticed that configuring BTE only FI-FI application does not solve the purpose. You need to assign function module FI_PRINT_DUNNING_NOTICE_PDF for all Application Area Indicator.
    Adding to IS-PS will allow to print for customer.
    This solved my problem. But this setting is global so you need to take care of it.

  • Gracefully terminating a blocked program that uses getRuntime().exec()

    I am executing a command line program using Runtime.getRuntime().exec()
    I am using two separate threads to read the standard and error output streams.
    I am using process.waitFor() to wait for the streams to be fully read.
    Some command line programs block when being read so I have a timer that calls process.destroy() after a timeout period, which seems to be working.
    I tried a few other techniques, such as closing the streams when the timout was up, but this did not work.
    Using destroy() feels like a heavy handed approach and I am wondering if this is the best way to terminate a program in this situation?
    Thanks

    Yes, we have no control over the external app (other than what the CLI provides).
    I am wondering how others are handling this and want to confirm that destroy() is the correct technique in this scenario.
    Thanks

  • Can I use NIDAQ32.dll with more than one application?

    We have some third party hardware and software which uses a PCI-6602 board and NIDAQ. I wanted to use some of the functions of the board for something else in a VB 6.0 program, but I always got errors with NIDAQ32.dll not being found if the third party software was running. It worked fine if I closed their software. I talked to NI, and they said you could not access a board with two applications at once. Fine, so I bought a PCI-6601 to put in the system to do my other functions. However, I still get the same error, saying the NIDAQ32.dll can not be found when I try to run my VB program. Anybody have a solution? I really need this to work, or this board is pretty useless to me...
    -Matt

    Matt,
    You CAN access a board with two applications at once. However, you can not access the same resource on a board with two applications at once. Analog input, analog output, and digital I/O are each their own separate resources. Each individual counter is a separate resource. Since your application works fine with the third-party software closed it sounds like your third-party software is doing something to the NIDAQ32.dll. I recommend contacting the developers of the third-party software and finding out what they are doing with the NIDAQ32.dll and if they even intended other applications to access the DLL at the same time.
    Ames
    Applications Engineering
    National Instruments

  • Intercept a mouseclick event with a background running application

    Ciao to everyone.
    My name is Alessandro and "i have a problem"...
    I want to count every click of my mouse with an application running in background.
    How can i intercept any mouseclick event, also those occurring out of the application?
    I work with Windows XP.
    Thanks and excuse me for my bad english.

    As far as we know when a Java swing application loses focus you can not handle the click being generated by the user.
    Have a look at the following source:
    http://java.sun.com/docs/books/tutorial/uiswing/events/mouselistener.html
    We have developed routines for that kind of handling in C+ and set up java JNI in order to retrieve them, but they are low level routines that need to handle interruptions from the main board (not recomended for average users).
    Answer provided by http://www.consultoriajava.com

  • Using iPad Mini with MacBook Chrome running OS X 10.5.8

    Hello,
    My MacBook is coming upto 4 years old and I run 10.5.8.  I recently bought an IPad Mini but it cannot connect to iTunes, and I cannot upgrade to iTunes version 7 as I am not running 10.6.8.
    Does this mean that I have to upgrade my OS?  If so, what's the best way to do this?
    Or am I best biting the bullet and investing in a new MacBook?
    Please help!!
    Steve

    There are two ways of looking at this. If the Mac can run Snow Leopard and the machine is still working well for you, you might be able to upgrade and get another year or two out the current machine.
    Here are the minimum requirements for Snow Leopard.
    General requirements
    Mac computer with an Intel processor
    1GB of memory
    5GB of available disk space
    DVD drive for installation
    Some features require a compatible Internet service provider; fees may apply.
    Copied from here.
    http://support.apple.com/kb/SP575
    You can try contacting Apple and see if they still have it available. I bought it for $29.00 at Best Buy about 18 months ago and some online stores still have it but you will get the best deal with Apple more than likely. I would try this number from the online store.
    Questions? Call 1-800-MY-APPLE
    The other way of approaching this is - if you can afford a new Mac - with the purchase of a new Mac and a new iPad Mini - you should be set for a few more years to come.

  • Ran into an interesting problem with getRuntime().exec()

    Hi,
    I'm trying to run a application using getRuntime().exec(). When I run the prgram from the command prompt everything goes ok, but when I start it from my java application, I get and error and the program exits.
    The executable I call withing my application is a bat file that sets the neccessary environmental variables (for now) and executes the right exe files. Exactly the same bat file I can start at the command prompt. I've also tried calling cmd /c to start the program and directly calling the exe started by the bat file.
    Below is the error I get. I have a hunch the program is made with Fortran.
    Can't read communication file
    Filing error number 7: FNF:File not found
    : Unable to open communications file to read
    There should be nothing wrong with my code and I can read and control the program. The problem occures when I try to change the mode withing the program, that makes it try to start a new process.
    What's the difference between starting a program manually through the command prompt and executing it using getRuntime().exec()?
    Br,
    Tom

    I'm just wondering how exec() can be different from using the command line in windows. I even execute my java app in the same directory and it uses the same commands.

  • GetRuntime().exec and wired string

    hello,
    I am trying to use getRuntime().exec in order to run a unix command. everything works fine while i test my code with a command like "pwd" or "ls". But the script i want to run has many special characters. The one that gives me a hard time is >. what can i do for that?
    here is my code:
    <%
         String result = "";
         String line; 
        String test = "ts-query -d test -f ascii \"select ?x where {<http://id.ecs.soton.ac.uk/person/6914> <http://xmlns.com/foaf/0.1/knows> ?x}\"";
        String cmd = "pwd";
        try {
                String[] command = {"/bin/sh", "-c", cmd};
                Process p = Runtime.getRuntime().exec(command);
                BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
                p.waitFor();
                System.out.println("return code: "+ p.exitValue());
                 while ((line = input.readLine()) != null) {
            System.out.println(line);
            result = result.concat(line + " ");
          input.close();
            } catch (IOException e) {
                System.err.println("IO error: " + e);
            } catch (InterruptedException e1) {
                System.err.println("Exception: " + e1.getMessage());
        %>

    First of all thanks a lot for helping me out.
    Well, i have to be doing something really wrong cos when i run this code:
    <%
         String result = "";
         String line;
        try { 
                Process p = Runtime.getRuntime().exec(new String[] {"java", "-server", "-version"});
                BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
                p.waitFor();
                System.out.println("return code: "+ p.exitValue());
                 while ((line = input.readLine()) != null) {
            System.out.println(line);
            result = result.concat(line + " ");
          input.close();
            } catch (IOException e) {
                System.err.println("IO error: " + e);
            } catch (InterruptedException e1) {
                System.err.println("Exception: " + e1.getMessage());
        %>i get no output but when i put the "/bin/sh", "-c", in fronf of the string then i get only the outupt that i would get if i was typing in the terminal "java" and hit return.
    Secondly, the way i understood your reply was to change my original string to lots of arguments in the .exec, something like this:
    Process p = Runtime.getRuntime().exec(new String[] {"ts","-query ","-d ","test ","-f ","ascii"," \"select"," ?x"," where"," {<http://id.ecs.soton.ac.uk/person/6914>"," <http://xmlns.com/foaf/0.1/knows> ","?x}\""});
    well in that case it only runs the "ts" and doesnt do anything else.
    The way i understood it is that every value that is in the String[] is going to be executed individually. like "typing" the first value to the terminal and hit return, then typing the second and hit return e.t.c
    i thought that because i dont get results the fault was that somehow the interpretation of the "<" was mistaken. Am i right?
    again, thanks a lot for your reply! I hope i will make it work with your help.
    p.s in case you are wondering the script i am trying to run has to do with semantic web and rdf querying.

  • Opening a new browser using Runtime.getRuntime().exec(cmd); under windows

    Can Runtime.getRuntime().exec(cmd); open a URL in to a new browser in wondows OS or ...can we force it to any specific browser insted on OS's default browser...
    It does open a new bowser under MAC but not under windows..
    cmd = "'rundll32 url.dll,FileProtocolHandler"+URL (windows)
    Thanks

    public class WindowsProcess
         public static void main(String[] args)
              throws Exception
              String[] cmd = new String[3];
              cmd[0] = "cmd.exe";
              cmd[1] = "/C";
              cmd[2] = "start";
              Process process = Runtime.getRuntime().exec( cmd );
              process = Runtime.getRuntime().exec( cmd );
    }When you run the above code you should get two open dos windows.
    Now just just enter some html filename and hit enter in each window. IE should start up separately in each window.
    Thats also what should happen if you specify the html file as the fourth parameter. A new process should be created and two separate windows should open with a browser in each.

  • GetRuntime().exec

    I am trying to send an email using getRuntime().exec on a Linux platform. The following is an example of the code that should execute.
    Process child = Runtime.getRuntime().exec("/bin/sh -c /bin/echo 'Body Text' | /bin/mail -s 'Subject' [email protected]");
    When I run the code nothing happens. I have even tried splitting the command into an array and executing the array and that doesn't work either.
    Any help or advice would be greatly appreciated.
    and yes I am aware of the Java Mail API.
    Nathan

    There is no shell invoking this oneYes there is, it's "/bin/sh" :) and a shell should
    handle input and output redirection.I'm only guessing, but it seems to be the case, as evidenced by earlier replies... He is invoking the shell, but is the shell interpreting the | symbol to mean "pipe the output", or is it literally just passing the character '|' to it (mixed in with the rest). That's why I'm suspecting that the | symbol is meant to be interpreted by the root 'shell', which in this case is plain-old exec() (which wouldn't do anything with it).

  • JS error while using input fields with type=file on XP SP2

    Hi all,
    we found a new problem in applications which use input fields with type=file running in a browser on Microsoft Windows XP with SP2.
    A typical test layout might look like:
    <html>
      <head>
        <title>File-Upload</title>
      </head>
      <body>
        <form action="/cgi-bin/upload.pl" method=post
              enctype="multipart/form-data">
          <input type=file size=50 maxlength=100000 name="file"
                 accept="text/*"><br>
          <button onclick="document.forms[0].submit();">Send</button>
        </form>
      </body>
    </html>
    When you add a link without the fully qualified path (for example pic01.jpg instead of c:\pictures\pic01.jpg) and click on the 'Send' button, nothing happens and you get a Javascript error 'Access denied'.
    The solution can be found in the MS Knowledge Base article 892442:
    http://support.microsoft.com/default.aspx?scid=kb;en-us;892442
    We still investigate this issue and will inform you about the further proceeding.
    Regards,
    Rainer

    Hi Yepin Jin,
    I am facing the same issue did you solved it?
    Regards,
    Orlando Covault

  • Runtime.getRuntime().exec(java method); - Passing strings between methods

    Hi all,
    I am using Runtime.getRuntime().exec(java xxxxxx); to run a java program from within a java program, i also need to pass a string to the new program. Does anyone know how to do this?
    Matt

    how would i retrive those strings in myApp as i want
    to put the values from them in a JLabelYou have a main method like this, right?
    public static void main(String[] args) { ... }
    args contains the array of strings passed to the app from the command line.

  • Need to use business objects with a project, please guide on basics.

    Hello
    I am a dotnet developer (asp.net with C#). I am sorry I dont know much about Business objects. Our client a financial firm wants to use Business object with a web based application. I couldn't got a clear and good understanding of Business object. The client just said Business objects allows dynamically creating reports even clients can create reports very easily even without knowing SQL.
    Kindly guide me about Business Object product and its what component I should check for using it. Please mention some links that can give me introduction.
    Thanks a lot,
    haansi

    Hi
    Business Objects is not just one tool. You should ask your client what they will use e.g. Crystal Reports or Web Intelligence.
    Here you can see half an hour Webinars that give you a good understanding of Business Objects:
    Webinars
    Regards
    Roland

  • Executing Windows shortcuts through getRuntime.exec

    Hello,
    I am writing a desktop component in which you should be able to drag and drop local windows icons and they will become an icon on my desktop.
    I am able to get the shortcut .lnk location by accessing the list flavor from the native drag and drop... for example if i drop a native shortcut i get:
    C:\Documents and Settings\pankaj\Desktop\Shortcut to eclipse.lnk
    i can even access the file system icon by:
              ImageIcon iconImage = (ImageIcon)FileSystemView.getFileSystemView().getSystemIcon(execFile);
              iconImage.setImage(iconImage.getImage().getScaledInstance(32,32,Image.SCALE_AREA_AVERAGING));
    but i tried to execute the .lnk command using getRuntime.exec(cmd); it didnt work obviously.. how can make this work?
    you can check out info on my project here:
    http://www-unix.globus.org/cog/wiki/moin.cgi/JavaCogDesktop
    thanks.
    pankaj

    Did you try "start"?
    new String [] { "cmd" , "/c", "start" , "path-to-my-shortcut" }

  • How to execute an application in Solaris using Runtime.getRuntime.exec() ?

    I am currently doing a project which requires the execution of Solaris applications through the use of Java Servlet with this Runtime method - Runtime.getRuntime.exec()
    This means that if the client PC tries to access the servlet in the server PC, an application is supposed to be executed and launched on the server PC itself. Actually, the servlet part is not an issue as the main problem is the executing of applications in different platforms which is a big headache.
    When I tried running this program on a Windows 2000 machine, it works perfectly fine. However, when I tried it on a Solaris machine, nothing happens. And I mean nothing... no errors, no nothing. I really don't know what's wrong.
    Here's the code.
    public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException
         response.setContentType("text/html");
         PrintWriter out = response.getWriter();
              Process process;                                                       Runtime runtime = Runtime.getRuntime();
              String com= "sh /opt/home/acrobat/";
              String program = request.getParameter("program");
              try
                        process = runtime.exec(com);
              catch (Exception e)
                   out.println(e);
    It works under Windows when com = "c:\winnt\system32\notepad.exe"
    When under Solaris, I have tried everything possible. For example, the launching of the application acrobat.
    com = "/opt/home/acrobat"
    com = "sh /opt/home/acrobat"I have also tried reading in the process and then printing it out. It doesn't work either. It only works when excuting commands like 'ls'
    BufferedReader read = new BufferedReader(new InputStreamReader(process.getInputStream()));Why is it such a breeze to execute prgrams under Windows while there are so many problems under Solaris.
    Can some experts please please PLEASE point out the errors and give me some advice and help to make this program work under Solaris! Please... I really need to do this!!
    My email address - [email protected]
    I appreciate it.
    By the way, I'm coding and compiling in a Windows 2000 machine before ftp'ing the .class file to the Solaris server machine to run.

    it is possible that you are trying to run a program that is going to display a window on an X server, but you have not specified a display. You specifiy a display by setting the DISPLAY environment variable eg.
    setenv DISPLAY 10.0.0.1:0
    To check that runtime.exec is working you should try to run a program that does not reqire access to an X Server. Try something like
    cmd = "sh -c 'ls -l > ~/testlist.lst'";
    alternatively try this
    cmd = "sh -c 'export DISPLAY=127.0.0.1:0;xterm '"
    you will also need to permit access to the X server using the xhost + command

Maybe you are looking for