Runtime.getRuntime().exec() append the parameters

Discussion in 'Java' started by balaguruthangaraj@gmail.com, Apr 20, 2009.

  1. Guest

    String[] command = new String[] {"CSCRIPT", vbsFile , "arg1" ,
    "arg2"};
    Runtime.getRuntime().exec(command);

    and

    Runtime.getRuntime().exec("CSCRIPT vbsfile arg1 arg2");

    In the above code arg1 and arg2 are append when I got these arguments
    in vbsfile.
    But When I excute the same in command prompt it works fine.
    Is anybody face this issue?
     
    , Apr 20, 2009
    #1
    1. Advertising

  2. In article
    <>,
    wrote:

    > String[] command = new String[]
    > {"CSCRIPT", vbsFile , "arg1" , "arg2"};
    > Runtime.getRuntime().exec(command);
    >
    > and
    >
    > Runtime.getRuntime().exec("CSCRIPT vbsfile arg1 arg2");
    >
    > In the above code arg1 and arg2 are append when I got these arguments
    > in vbsfile.


    I don't understand what difference you are seeing. Can you paste a
    verbatim transcript of your results? Is your OS case sensitive? [vbsFile
    versus vbsfile]

    > But When I excute the same in command prompt it works fine.
    > Is anybody face this issue?


    Are your actual arguments correctly quoted so that they may be "broken
    into tokens using a StringTokenizer," as discussed here:

    <http://java.sun.com/javase/6/docs/api/java/lang/Runtime.html>

    --
    John B. Matthews
    trashgod at gmail dot com
    <http://sites.google.com/site/drjohnbmatthews>
     
    John B. Matthews, Apr 20, 2009
    #2
    1. Advertising

  3. wrote:

    > In the above code arg1 and arg2 are append when I got these arguments
    > in vbsfile.
    > But When I excute the same in command prompt it works fine.
    > Is anybody face this issue?


    What exactly are the values of arg1 and arg2. If they contain
    wildcards or other things that are interpreted by the command-
    interpreter working in a command shell, you have to call that
    command-interpreter from Java instead of calling cscript.

    Also you might make sure that cscript and/or your Visual Basic
    file are not relying on environment variables that are not set
    within your Java-process.

    This is all I can tell without knowing more about the calling
    parameters and error-messages that are returned from the
    called process.


    Regards, Lothar
    --
    Lothar Kimmeringer E-Mail:
    PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)

    Always remember: The answer is forty-two, there can only be wrong
    questions!
     
    Lothar Kimmeringer, Apr 21, 2009
    #3
  4. Guest

    Hi,

    There was no error message on this.
    The vbs script was executed , so no necessary to set environment
    variables for this.
    arg1 and arg2 have no wildcards just alphabet only.
    Note that It does not happen at all time.Some time it succeed some
    time the parameters appends.

    Machine details:

    Processor: Intel Xeon Cpu E5420 @2.50Ghz
    OS: Windows Server 2003 Standard SP2



    On Apr 21, 4:53 pm, Lothar Kimmeringer <>
    wrote:
    > wrote:
    > > In the above code arg1 and arg2 are append when I got these arguments
    > > in vbsfile.
    > > But When I excute the same in command prompt it works fine.
    > > Is anybody face this issue?

    >
    > What exactly are the values of arg1 and arg2. If they contain
    > wildcards or other things that are interpreted by the command-
    > interpreter working in a command shell, you have to call that
    > command-interpreter from Java instead of calling cscript.
    >
    > Also you might make sure that cscript and/or your Visual Basic
    > file are not relying on environment variables that are not set
    > within your Java-process.
    >
    > This is all I can tell without knowing more about the calling
    > parameters and error-messages that are returned from the
    > called process.
    >
    > Regards, Lothar
    > --
    > Lothar Kimmeringer                E-Mail:
    >                PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
    >
    > Always remember: The answer is forty-two, there can only be wrong
    >                  questions!
     
    , Apr 25, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Zsolt Koppany
    Replies:
    2
    Views:
    7,292
    SaintMagoo
    Mar 5, 2011
  2. MARTIN Herve \(EXT\)
    Replies:
    1
    Views:
    1,512
    Anthony Borla
    Nov 27, 2003
  3. paul brown
    Replies:
    3
    Views:
    5,642
    deepa gr
    Feb 17, 2009
  4. Andrew Regan

    Runtime.getRuntime().exec() ??

    Andrew Regan, Jun 28, 2004, in forum: Java
    Replies:
    3
    Views:
    941
    Yu SONG
    Jun 30, 2004
  5. S!mb@
    Replies:
    3
    Views:
    7,738
    Roedy Green
    Jul 19, 2004
Loading...

Share This Page