Executing an hp unix command by using java code

i'm trying to execut the "chmod" command on my jsp as follows :
String cmd = "chmod 644 "+fileName;
Process process;
process=Runtime.getRuntime().exec(cmd);
but i got the following exception:
java.io.IOException: chmod: not found
     at java.lang.UNIXProcess.forkAndExec(Native Method)
     at java.lang.UNIXProcess.<init>(UNIXProcess.java:86)
     at java.lang.Runtime.execInternal(Native Method)
     at java.lang.Runtime.exec(Unknown Source)
     at java.lang.Runtime.exec(Unknown Source)
     at java.lang.Runtime.addShutdownHook(Unknown Source)
     at java.lang.Runtime.addShutdownHook(Unknown Source)
     at receiveJobAppInput.jspService(_receiveJobAppInput.java:358)
     at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java, Compiled Code)
     at oracle.jsp.runtimev2.JspPageTable.compileAndServe(JspPageTable.java, Compiled Code)
     at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java, Compiled Code)
     at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java, Compiled Code)
     at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java, Compiled Code)
     at javax.servlet.http.HttpServlet.service(HttpServlet.java, Compiled Code)
     at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java, Compiled Code)
     at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java, Compiled Code)
     at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java, Compiled Code)
     at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java, Compiled Code)
     at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java, Compiled Code)
     at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java, Compiled Code)
     at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java, Compiled Code)
     at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java, Compiled Code)
     at java.lang.Thread.run(Unknown Source)
can anyone give me a hint why this happend?

What about exec'ing this?
String [] {"chmod" ,"644" , "fileName" }

Similar Messages

  • Using Unix command lines in java code

    I was wondering if there was a way to run a unix command in java code. I know in C++ there is popen, but i don't know of a way in java. The command i need to run is the whois "domain name" command. Any help would be great!
    jarad

    try something like this:
      public static String whois(String domain) throws IOException {
        BufferedReader is = null;
        Process p = null;
        String result = "";
        p = Runtime.getRuntime().exec("whois " + domain);
        is = new BufferedReader(new InputStreamReader(p.getInputStream()));
        String line;
        while((line = is.readLine()) != null)
          result += line;
        return result;
      }

  • Spanish characters getting garbled while executing command using Java code

    Hi,
    I try to execute a command using java code. output of the command contains spanish characters. Few of these characters getting garbled after the command execution.
    Runtime r = Runtime.getRuntime();
              Process p = null;
    String pgm="ipconfig /all";
              try
                        p = r.exec(pgm);
    BufferedReader br=new BufferedReader(new InputStreamReader
                                  (p.getInputStream()));
    while((val = br.readLine()) != null){ System.out.println(val);
              catch (Exception e)
                        return (null);
    I tried to run the code using -Duser.language=es -Duser.region=ES -Dfile.encoding=Cp850, but this did nt help. I could see the outputs properly in command prompt,
    If i redirect the output to a text file , it is getting garbled,
    Please let me know to solve this issue.

    884543 wrote:
    Hi,
    I try to execute a command using java code. output of the command contains spanish characters. Few of these characters getting garbled after the command execution.
    Runtime r = Runtime.getRuntime();
              Process p = null;
    String pgm="ipconfig /all";
              try
                        p = r.exec(pgm);
    BufferedReader br=new BufferedReader(new InputStreamReader
                                  (p.getInputStream()));
    while((val = br.readLine()) != null){ System.out.println(val);
              catch (Exception e)
                        return (null);
    I tried to run the code using -Duser.language=es -Duser.region=ES -Dfile.encoding=Cp850, but this did nt help. I could see the outputs properly in command prompt,
    If i redirect the output to a text file , it is getting garbled,
    Please let me know to solve this issue.Set the character set to UTF-8 to your InputStreamReader, for More details on usage refer the java api :
    http://download.oracle.com/javase/6/docs/api/java/io/InputStreamReader.html

  • To run a command using java code

    hi all,
    There is a command
    "java -jar selenium-server.jar -interactive"
    which i am running through command prompt after going to D:\MyFolder\Examples .
    i want to execute this command using java code .please help

    subratjyetki wrote:
    please answer in detail or if posible can u give the code for thisThe detail is given in the reference. Why don't you read it?
    I could give you the code but it will cost you ?100 per hour.

  • Monitor Unix Mail Queue using java

    Hi! ,
    I want to monitor unix mail queue using java. how can i proceed..
    Please advice..
    Thanks..
    Ganesh

    Google and see if there is an API which lets you monitor it.
    Kaj

  • How to get the values from struct data type using java code..?

    Hi ,
    I am newer to java.
    we are using oracle database.
    How to get the data from struct data type using java code.
    Thanks in Advance.
    Regards,
    kumar

    Hi Rajeev,
    To retrieve a FilterContainer you will need to traverse the report structure:
    ReportStructure boReportStructure = boDocumentInstance.getStructure();
    ReportContainer boReportContainer = (ReportContainer) boReportStructure.getReportElement(0);
    FilterContainer boFilterContainer = null;
    if (boReportContainer.hasFilter()) {
         boFilterContainer = boReportContainer.getFilter();
    } else {
         boFilterContainer = boReportContainer.createFilter(LogicalOperator.AND);
    Calling boDocumentInstance.getStructure() will retrieve the entire structure for the document.
    Calling boReportStructure.getReportElement(0) will retrieve the structure for the first report of the document.
    Hope this helps.
    Regards,
    Dan

  • How to change InputField background color using Java Code

    Hi,
    In my application use will enter some set of Cost Centers in a table and submits request.
    In return i will get a list of invalid cost centers which i need to display in a table with input field
    In that table all cost centers will displayed, but invalid cost centers should be highlighted or background color should some other color. like red or yellow.
    Is it possible using java code to change a input field color.
    Please help me.
    Thanks

    Hi,
        declare a error message in message pool and declare a method say "checkCostCenters " and in this method, u can check whether it is a valid cost center .. if it is invalid cost center , then throw the erro message using the below code :
    wdComponentAPI.getMessageManager().reportContextAttributeMessage(
                        inputfieldattibutePointer, IMessageProgramPlanComp.ur error message,
                        new Object[] );
    for getting pointer and label use the below code:
    IWDAttributePointer inputfieldPointer = URNODEELEMENTElement
                        .getAttributePointer(URNODEELEMENT.ATTRIBUTENAME);
              String inputfieldLabel = wdContext.nodeURVALUENODE.getNodeInfo()
                        .getAttribute(URNODELEMENT.ATTRIBUTE).getSimpleType()
                        .getFieldLabel();
    hope it helps..
    Thanks and Regards

  • How to change the properties of a directory using java code

    Hai All,
    I need to change the properties of directory( websharing).
    Can i do this using java code.
    Regards,
    Charan

    I need to change the properties of
    directory( websharing).
    an i do this using java code.Depends on whether the server has a Java API to do it. Most likely it hasn't.

  • How to print/list all the groups/users present in Weblogic using Java code

    Hi,
    Weblogic version : 11.1.1.5
    How to print/list all the groups/users present in Weblogic using Java code
    I want to make a remote connection to Weblogic server and print all the users/groups present in it.
    I have gone through the below mentioned site, but I cannot use the same approach since most of the API' are deprecated for example "weblogic.management.MBeanHome;"
    http://weblogic-wonders.com/weblogic/2010/11/10/list-users-and-groups-in-weblogic-using-jmx/
    Thanks in advance,
    Edited by: 984107 on 05-Feb-2013 05:26
    Edited by: 984107 on 05-Feb-2013 22:59

    see this http://www.techpaste.com/2012/06/managing-user-groups-wlst-scripts-weblogic/
    Hope this helps.

  • How to dynamically configure JPA setting at runtime using java code?

    Hi,
    I am new to EJB 3.0 and JPA. I am trying to help my company to deploy the use of JPA in EJB3.0. Currently, i am trying out with OpenJPA in IBM Webshpere Application Server 7.0. We have four different WAS servers running for testing, system integration testing, user testing and production respectively, and in each region, the configurations for data source, JDBC username and password, schema, etc are different. So i think i would need to configure the JPA setting during runtime using Java code that determines which is the environment. And apparently i am stuck with the limited knowledge i have.
    1) I understand that i could override the JDBC in the persistence xml by creating entity manager using entity manager factory. But is it possible that i do similar thing by using inejction of persistence context on entity manager to obtain a container managed entity manager?
    2) Alternatively, it is possible to create multiple persistence unit in the XML and inject different PU to the entity manager, am i right? But how to inject dynamically since @PersistenceContext(unitName="xxx") only accepts constant declaration.
    3) Is it possible that the JDBC username and password are read from properties file?
    Thanks for your help in advance!

    Hi
    Thanks for the reply.
    Are you saying that i have to configure the data source authentication to the backend DB2 using the JAAS-J2C? Correct me if i am mistaken. I guess i am unable to do so as the application server setup only contains one data source, and the server hosted a number of applications. Every applications has their own JDBC username and password supply to the data source (the ID supplied at the DB2 side will decide which resource can access) and thus, i have to supply the username and password at runtime. Talked to the server guy and seems that it is not feasible to have seperate datasource for each applications as considered to the volume of applications hosted inside the server.
    Any suggestion?

  • Read an excel file using java code

    Hi,
    I want to create an excel file on the client machine based on the personal details entered on the web page. And I want to save the file on the client machine in the form of CSV. Then I want to read the contents of the spreadsheet using Java Code from the using servlets. Can I read the contents of the file directly from the client machine or do i need to save the file on the server and then read the contents of it. Please help me solve this.

    Hi,
    I want to create an excel file on the client machine
    based on the personal details entered on the web
    page. And I want to save the file on the client
    machine in the form of CSV. Then I want to read the
    contents of the spreadsheet using Java Code from the
    using servlets. Can I read the contents of the file
    directly from the client machine or do i need to save
    the file on the server and then read the contents of
    it. Please help me solve this.As stated I am rather certain that is impossible.
    Servers don't access the file systems of client machines.

  • Creating a folder in current workspace using java code

    Hi Experts,
    I need to create a folder and some file in the workspace of NWDS user. Can someone please suggest how can i find out the workspace of user using JAVA code.
    IWorkspaceRoot is not working in NWDS.
    Regards
    Pranav

    Hi Pranav,
    Tell me if you want to create this folder at run time or in NWDS while developing application.
    If you want to create it at the time of development just change your perspective to Java perspective and from there you can see the entire project structure and from there you can create desired files / folders.
    Ninad

  • How do I produce an excel file using java code

    How do i produce an excel file using java code.
    If it is possible would ne one have ne source code as an example.
    I have tried looking up information on outputing the information to a *.csv file but unfortunality i have had no luck in finding any information. To be exact ne source code.
    Thanks
    Lee

    That's what I use and I'd be the first to admit that it's very messy. But it works. Go use Google and see what else you can find.

  • In Struts is it possible to use java code  in jsp?

    in Struts Tag Program in jsp pages is it efficient to use java code? Please explain?

    No issues.. you can use java code... in jsp struts
    based framework..
    SJYou can use Java code as scriptlets in any JSP, but that doesn't mean there are no issues.
    I would say it's a bad idea for the following reasons:
    (1) Scriptlet code is difficult to read when mingled with HTML
    (2) You can't unit test scriptlet code
    (3) It increases the chance that business logic will leak into pages where it doesn't belong.
    Better to use a well-proven tag library like JSTL or the Struts taglibs and keep all scriptlets out of your JSPs.
    %

  • How to use Java code inside WebDynpro-ABAP

    Hi,
        How to use Java code inside WebDynpro-ABAP.
    Could any one provide sample code.
    Cheers,
    Sam

    Hi Sam,
    We can't Bring Java Inside the ABAP. Both are running in different Environments.
    and also ABAP Codes are runs on BASIS.
    -Basis is a middleware between ABAP codes and Ur OS.
    -Contains set of programs to load,RUN,intepret the ABAP program..
    So Both are Different.
    Regards,
    Ramganesan K.

Maybe you are looking for

  • I bought an app, but I can't download it

    Hi, I bought the "South Park Imaginationland" game directly from my Ipod Touch and a box appeared, saying that I needed to connect my ipod to get the game download on it. I connected my Ipod and checked the "available downloads" in the store menu, bu

  • Today only, Stocks and Weather incredibly slow...

    Getting info for either app is taking far longer than usual and has occurred on 2 Touch's we own, with no other wifi apps affected. Anyone else notice that today, Stocks and Weather are very slow to update? They are taking about 15-25 seconds instead

  • Using an 8.0 client with a 6.5 server

    We currently have an application running on AIX and Tuxedo Client 6.5, that connects to a 6.5 server. We are thinking on migrating the application to Linux, and found that Linux is only supported for Tuxedo 7.1 and higher. Would there be any problem

  • EJB QL: Passing array of enum to SELECT * WHERE a IN () clause

    Hello, I am trying to pass an array of enum to EJB QL as followed: em.createQuery("FROM OrderInfo o WHERE o.ordStatus IN (:ordStatus)")                  .setParameter("ordStatus", ordStatsStr)Note that o.ordStatus is of type enum OrderStatus. I've tr

  • Finder not updating when files change

    I've started experiencing a really irritating problem whereby the Finder does not automatically update the view of a directory when I save a file in it. It seems to ignore all file system changes. This never used to happen. In fact, when I first inst