System calls using JSP

Hi all,
I have the following code in a class file:
Process process = Runtime.getRuntime().exec("pscp <file> <destination>");
process.waitFor();
Now when this class is executed on command line, it executes fine, but when it is called in a class (executed via a jsp page), it does not execute at all.
Anyone have this scenario happen to them before?

Is the pscp command available in the executable path? Maybe your Servlet-Container changes the path during startup?
Try to execute a basic command like "cmd.exe /c dir" (assuming you use windows) and capture the output to see if that works:
<%!
  public String escape(char c) {
    switch(c) {
      case '<':
        return "<";
      case '>':
        return ">";
      default:
        return "" + c;
%>
<pre>
<%
  Process p = Runtime.getRuntime().exec("cmd.exe /c dir");
  java.io.InputStream is = p.getInputStream();
  int i = 0;
  while((i = is.read()) != -1) {
    out.print(escape((char)i));
  p.waitFor();
%>
</pre>

Similar Messages

  • Internal system call used by "ps" command

    Hi All,
    Can any one let me the internal system call used by "ps" command to retrieve the process information. I want to use the same system call in my program to get list of information about processes currently running in the system. I do not want to use the "ps" command in my code.

    Justin_Samuel wrote:
    Hi All,
    Can any one let me the internal system call used by "ps" command to retrieve the process information. I want to use the same system call in my program to get list of information about processes currently running in the system. I do not want to use the "ps" command in my code.You can access the /proc filesystem for getting information about
    processes, even more than is available via ps.
    Have a look at:
    man -s 4 proc

  • Unix System Calls using Java

    Hi!
    Can anyone tell me how to do Unix System Calls in my Java program?
    If possible please give me the java code for it taking one unix system call as an example.
    Thanks in advance
    Raj

    do you mean firing off a shell command, or making actual kernel API calls or C library calls?
    for shell commands, have a look at Runtime.exec(). for kernel calls, use JNI. the JNI FAQ mentions something called "shared stubs" that may be of use:
    http://java.sun.com/products/jdk/faq/jnifaq.html
    cheers,
    p

  • Linux system call used in process creation from java?

    Does Runtime.getRuntime().exec("some command"); bottom out in vfork, fork or something else on Linux versions of the java 1.5 jdk?

    If the second, get the VM source and look. Or run a test case using the system call tracing utility "strace".

  • Making Palm System calls using J2ME

    Hi is there anyway where I can use the old KJava API or even the J2ME to make system calls such as
    DmFindDatabase(0,"Something")
    SysAppLaunch(0,dbID,0,cmdPrintChars,theChars,&result);
    axlrose82

    [axlrose82],
    At the moment, we are quite certain that the kVM for the PalmOS do not contain any API that allows a developer to make system calls to the PalmOS itself. The CLDC/MIDP specification does not specify any native system calls access any of the native apps. I can see from your code that you are trying to access the Palm database but I'm afraid you are out of luck with the current specs.
    HTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Sql*loader using JSP

    wht is the way of using sqlldr in JSP script to load data Oracle DB from a csv file.
    i know how we do sqlldr in cmd.
    can we provide the sqlldr command to system by using jsp if yes how?

    SQL*Loader is a command-line utility. In theory, since Java can call out to the operating system, you could invoke SQL*Loader on the application server to load data into Oracle. It would probably be more appropriate, though, to copy the CSV to the database server and make use of an external table in the database to do the load.
    Justin

  • Quotes in parameters to a system call

    Hello,
    From my program, which is a servlet, I'm making a system call using -
    (Runtime.getRuntime()).exec(cmd).waitFor();
    where cmd is a previously defined String giving the call to execute. The problem here is seen when the parameters to cmd (which happens to be a perl script in this case) include one or more where the values are strings which include spaces, and hence are in double quotes. For example, if I want to execute -
    /usr/local/bin/myScript.pl -t "Some text"
    When executed from a prompt this works fine and -t has the value -
    Some text
    However when called from my Java program as above, the script instead thinks that -t has the value -
    "Some
    I'm not sure how this is coming about, but it seems to be a feature of the way Java executes the command. Has anybody seen this before? How do I stop it happening? I have tried every combination of quotes of which I can think, but nothing seems to do what I want, and the command string when printed to screen, for example, looks exactly as it should.
    Thanks,
    Joe Partridge

    Or sat all separate parts in String[] like this:
    String[] cmds={"/usr/local/bin/myScript.pl","-t","Some text"}
    and call:
    (Runtime.getRuntime()).exec(cmds).waitFor();
    That also works and you don't have to remember to put quotes all the time
    Gil

  • How to get the size of physical memory by using system call ?

    how to get the size of physical memory by using system call ?What system call can be used for me to get the size of physical memor? thanks.

    %vmstat 3
    procs memory page disk faults cpu
    r b w swap free re mf pi po fr de sr s0 -- -- -- in sy cs us sy id
    0 0 0 3025816 994456 4 19 6 0 0 0 0 8 0 0 0 459 253 139 1 1 99
    0 0 0 2864688 777408 0 2 0 0 0 0 0 3 0 0 0 428 134 175 0 1 99
    0 0 0 2864688 777408 0 0 0 0 0 0 0 7 0 0 0 448 112 166 0 0 100
    one interesting observation about vmstat I found out is (mostly on Solaris)
    the first line of information always off chart, so I usually do a few interval to get constant result.
    if you use linux
    just
    cat /proc/meminfo

  • Need guidance on using ddi_regs_map_setup solaris system call

    Hi all,
    Am a beginner in using Sun Solaris.
    I am working on porting our source code from linux to solaris.
    In Linux we are using inb/outb to read/write to keyboard data port(0x60) .
    I know that there is an equivalent system call for inb/outb in solaris. But in man page(of sun os) it is mentioned that inb/ outb are obsolete. It was mentioned that we can use ddi_get8/ddi_put8 functions respectively.
    ddi_get8 call requires ddi_acc_handle_t as a parameter which we can get it from ddi_regs_map_setup system call.
    Syntax for this call is:
    int ddi_regs_map_setup(dev_info_t *dip, uint_t rnumber,
    caddr_t *addrp, offset_t offset, offset_t len,
    ddi_device_acc_attr_t accattrp, ddi_acc_handle_t handlep);
    Please let me know where does the 0x60 port number fits in the above system call and what does these parameters rnumber, offset, len corresponds to ?

    Hi,
    The Fault_PC 0x13575e8 tells you exactly where you
    die. I assume you have used this in mdb on
    the core file to find you are dying in the ddi_get8 call?
    Are you checking return value of ddi_regs_map_setup?
    Are you sure the register you are accessing is in register set 1?
    Are there other places prior to the panic where
    the ddi_get/ddi_put routines work correctly? A bus error
    here generally means the location you are trying to access
    does not exist on the device. (It could also be alignment,
    but not with ddi_get8). The address
    looks like 1fe.02001400, which looks like a possibly
    valid address in I/O space.
    I would print the value of wc->ioaddr to make sure
    it is a valid virtual address.
    Hi,
    I'm in the middle of porting a device driver for a
    PCI card from linux to solaris (it's wcfxo from
    zaptel - part of asterisk).
    >
    WARNING: [AFT1] Bus Error on System Bus in privileged
    mode from CPU0 Data access at TL=0, errID
    0x0000000b.985ccf88
    AFSR 0x00000000.84000000<PRIV,BERR> AFAR
    AFAR 0x000001fe.02001400
    AFSR.PSYND 0x0000(Score 05) AFSR.ETS 0x00
    0x00 Fault_PC 0x13575e8
    UDBH 0x0000 UDBH.ESYND 0x00 UDBL 0x0000
    0000 UDBL.ESYND 0x00
    panic[cpu0]/thread=2a10007dd40: [AFT1] errID
    0x0000000b.985ccf88 BERR Error(s)
    See previous message(s) for detailsThe actual code which seems to cause the panic is:
    #define inb(a)          ddi_get8(wc->devhandle, a)
    ints = inb(wc->ioaddr + WC_INTSTAT);where there initialisation includes:
    static struct ddi_device_acc_attr dev_attr = {
    DDI_DEVICE_ATTR_V0,
    DDI_STRUCTURE_LE_ACC,
    DDI_STRICTORDER_ACC
    ddi_regs_map_setup(wc->dip, 1, &wc->ioaddr, 0, 255,
    &dev_attr,
    &dev_attr, &wc->devhandle);I've tested the same card in a linux x86 box, and it
    works fine, so I'm happy it's not a hardware
    problem.
    Any suggestions on what might be causing this?
    Thanks,
    Simon

  • Is it posssible to lunch one application from the client system using JSP

    Is it possible to Lunch one application from the client system using JSP or Servlet .If it is possible then how can we do that ?
    Thanks in advance
    Sil

    If its a java application - yes. You can use jnlp and web start.
    ram.

  • How to use system call in assembler

    I write codes to display the dictionary using C,
    and it can run well,and then I want to use system call
    in assembler to realize the same function ,but it doesn't
    display the dictionary,how to correct it?
    Look:
    //C
    #include <stdio.h>
    int main()
    char *name[2];
    name[0]="/bin/ls";
    name[1]=NULL;
    execve(name[0],name,NULL);
    return 0;
    //Assembler
    .data
    msg:.string "/bin/ls"
    .text
    .global _start
    _start:
    movl $0xb,%eax
    movl $msg,%ebx
    mov $msg,%ecx
    movl $0,%edx
    int $0x80
    movl $1,%eax
    movl $0,%ebx
    int $0x80

    If you compile with -Wwrite-strings, as I like to do for new code, you'll notice it warns about assigning the address of read-only memory to a plain char *. You might want to declare name as follows to avoid accidentally trying to modify it:
    char const *name[2];
    But as for your question. The execve system call requires a pointer to a list (array) of pointers to strings in %ecx. You are passing it a pointer to a single string, which means it will try to interpret the string ("/bin/ls")as a series of pointers to strings, with potentially disastrous (and certainly weird) results.
    Last edited by Trent (2012-12-28 15:31:38)

  • How can I use system call in kernel loadable module?

    Hi,
    I want to use system call (shmat, mmap,...) in kernel module.
    When kernel module is loaded, it cause system error (undefined symbol name 'shmat', 'mmap').
    How can I use system call in kernel module ?
    Thanks in advance.
    david joo

    You cannot use system calls in the kernel modules.
    Read 'Writing Device Drivers' answerbook - it lists the set of interfaces (known as DDI/DDK) that are supposed to be used instead.
    Hope this helps...
    --I.

  • Calling bean using jsp

    i've installed tomcat v3.3.2, and set the environment variable as normal procedure has mentioned..i have j2sdk 1.4.2_08, and recently has try to expirment calling java beans using jsp file located at D:\jakarta-tomcat-3.3.2\webapps\helloworld.jsp, and my bean file is located at D:\jakarta-tomcat-3.3.2\webapps\ROOT\WEB-INF\classes\com\bean\test\hellobean.class, and my hellobean.java source is :
    package com.bean.test;
    public class hellobean implements java.io.Serializable
    private String Name;
    public hellobean() {}
    public String getName()
    {return Name;}
    public void setName(String Name)
    {this.Name=Name;}
    and my jsp file source:
    <html>
    <body>
    <jsp:useBean id="hello" class="hellobean">
    <jsp:setProperty name="hello" property="Name" value="Alan"/>
    </jsp:useBean>
    <h1>hello, <jsp:getProperty name="hello" property="Name"/></h1>
    </body>
    </html>
    and when i run start.bat and type http://localhost:8080/helloworld.jsp, it gave me this error:
    Error: 500
    Location: /helloworld.jsp
    Internal Servlet Error:
    org.apache.jasper.JasperException: hellobean
         at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:140)
         at org.apache.jasper.compiler.GetPropertyGenerator.generate(GetPropertyGenerator.java:59)
         at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate(JspParseEventListener.java:747)
         at org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventListener.java:176)
         at org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEventListener.java:131)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:169)
         at org.apache.tomcat.facade.JasperLiaison.jsp2java(JspInterceptor.java:765)
         at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:706)
         at org.apache.tomcat.facade.JspInterceptor.preInitCheck(JspInterceptor.java:493)
         at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:413)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:874)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:790)
         at org.apache.coyote.tomcat3.Tomcat3Adapter.service(Tomcat3Adapter.java:64)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
         at java.lang.Thread.run(Thread.java:534)
    Root cause:
    java.lang.ClassNotFoundException: hellobean
         at org.apache.tomcat.util.depend.DependClassLoader12Impl.loadClassInternal1(DependClassLoader12.java:205)
         at org.apache.tomcat.util.depend.DependClassLoader12Impl$1.run(DependClassLoader12.java:78)
         at java.security.AccessController.doPrivileged(Native Method)
         at org.apache.tomcat.util.depend.DependClassLoader12Impl.loadClass(DependClassLoader12.java:76)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
         at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:138)
         at org.apache.jasper.compiler.GetPropertyGenerator.generate(GetPropertyGenerator.java:59)
         at org.apache.jasper.compiler.JspParseEventListener$GeneratorWrapper.generate(JspParseEventListener.java:747)
         at org.apache.jasper.compiler.JspParseEventListener.generateAll(JspParseEventListener.java:176)
         at org.apache.jasper.compiler.JspParseEventListener.endPageProcessing(JspParseEventListener.java:131)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:169)
         at org.apache.tomcat.facade.JasperLiaison.jsp2java(JspInterceptor.java:765)
         at org.apache.tomcat.facade.JasperLiaison.processJspFile(JspInterceptor.java:706)
         at org.apache.tomcat.facade.JspInterceptor.preInitCheck(JspInterceptor.java:493)
         at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:413)
         at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:874)
         at org.apache.tomcat.core.ContextManager.service(ContextManager.java:790)
         at org.apache.coyote.tomcat3.Tomcat3Adapter.service(Tomcat3Adapter.java:64)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:793)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:702)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:571)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:644)
         at java.lang.Thread.run(Thread.java:534)
    can anybody help me? thanks

    Hi
    Same problem as above and did everything as posted here in the page, but still doesn't solve my problem.
    Here's the bean :
    package com.partha;
    public class CounterBean
    private int counter=0;
    public int getCounter()
    return counter;
    public void incrementCounter()
    counter++;
    Here's the JSP Page :
    <%@ page language="java" %>
    <jsp:useBean id="session_counter" class="com.partha.CounterBean" scope="session"/>
    <jsp:useBean id="application_counter" class="com.partha.CounterBean" scope="application" />
    <html>
         <head>
              <title>Exercise 3</title>
         </head>
         <body>
              <%= session_counter.incrementCounter() %>
              <%= application_counter.incrementCounter()%>
              The number of times this session was accessed :
              <jsp:getProperty name="session_counter" property="counter" />
              <br>
              The number of times this page was accessed :
              <jsp:getProperty name="application_counter" property="counter" />
         </body>
    </html>
    I am still getting a classnot found exception . Here's what I am getting :
    java.lang.ClassNotFoundException: com.partha.FormBean
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1407)
         at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1252)
         at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:133)
         at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:650)
         at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:507)
         at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:983)
         at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1025)
    Please help me out ..

  • How to call java method using jsp

    how to call java method using jsp.....
    anyone can help me.....i having problem here...coz i very new in java and jsp.....
    thanks.....

    keep an eye on this person's thread...they have code there and everything.
    http://forum.java.sun.com/thread.jspa?threadID=777263&tstart=0

  • How to get swap size by using system call?

    How can I get the size of swap.What system call or library Routines can be used? please help me.

    Hi,
    Threre's an interface called swap_ctl by wich you can get more information related to virtual memory. Here's an example:
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <sys/stat.h>
    #include <sys/swap.h>
    #include <sys/param.h>
    int
    main(int argc, char*argv[])
    swaptbl_t *st;
    int swap_count, i;
    long long swap_total=0, swap_avail=0;
    long pgsize_in_kbytes = sysconf(_SC_PAGE_SIZE) / 1024L;
    if ((swap_count=swapctl(SC_GETNSWP, NULL)) == -1)
    perror("swapctl(SC_GETNSWP)"), exit(-1);
    if (swap_count == 0)
    (void)printf("No swap files/partitions allocated\n"), exit(0);
    * Although it's not particularly clear in the documentation, you're
    * responsible for creating a variable length structure (ie. the
    * array is within the struct rather than being pointed to
    * by the struct). Also, it is necessary for you to allocate space
    * for the path strings (see /usr/include/sys/swap.h).
    st = (swaptbl_t*)malloc(sizeof(int) + swap_count * sizeof(struct swapent));
    if (st == NULL)
    perror(argv[0]), exit(-1);
    st->swt_n = swap_count;
    for (i=0; i < swap_count; i++) {
    if ((st->swt_ent.ste_path = (char*)malloc(MAXPATHLEN)) == NULL)
    perror(argv[0]), exit(-1);
    if ((swap_count=swapctl(SC_LIST, (void*)st)) == -1)
    perror("swapctl(SC_LIST)"), exit(-1);
    for (i=0; i < swap_count; i++) {
    swap_total += st->swt_ent.ste_pages * pgsize_in_kbytes;
    swap_avail += st->swt_ent.ste_free * pgsize_in_kbytes;
    (void)printf("Total swap = %lld available swap = %lld\n",
    swap_total, swap_avail);
    return 0;
    There's a very interesting document about Solaris Kernel/Performance Stats available at http://www.idiom.com/~gford/admin/howto/perf.html. Very interesting.
    Hope this helps

Maybe you are looking for

  • Why can't I see the video icon in phone booth now that I upgraded to lion

    I upgraded my mac to Lion and can no longer make videos in phonebooth only the camera icon is available.

  • Monitoring of topLink internal connections  pool

    we wish to monitoring use of Toplink internal connections pool : numbers maximum used, a minimum number used. we know to do it with the external pool (OracleAS) but not with the internal pool. Regards

  • Release Order with ref to Contract

    Dears, Where we can find the release order No. which were created with reference to contrac.?  Thanks,

  • Adobe Reader frozen

    Adobe Reader is frozen and I cannot print screen. I really need the form on the screen with the date I have completed on it. Is there any way to print this docuement. The screen has been frozen for about 1.5 hours. IO am afriad because this dat is ve

  • BSP tableview Iterator

    Dear Experts, I am currently working with BSP tableview iterator. I have use many internal tables and the data are store in my class. My question is how can i use certain data which already store in my class and display them in my tableview with iter