Results 1 to 2 of 2
  1. #1
    cool is offline Member
    Join Date
    Nov 2010
    Posts
    20
    Rep Power
    0

    Default passing arument to runtime.getRuntime() method

    Hi,

    i have a code which creates scheduled task by executing runtime.getruntime method as follows,


    str = "schtasks /create /sc hourly /mo "+hrs +" /tn " +taskname+ " /tr python filename.py argument /ru " +username+ " /rp password";

    Runtime run = Runtime.getRuntime();
    Process pr = run.exec(str);


    now in file name i need to pass string "python filename.py argument"

    i tried creating a string like

    String filename = "python filename.py argument";

    but its not working,
    at command prompt it runs if i pass file name within quotes

    means

    at command prompt
    schtasks /create /sc hourly /mo hrs /tn taskname /tr "python filename.py argument" /ru username /rp password

    works
    and
    schtasks /create /sc hourly /mo hrs /tn taskname /tr python filename.py argument /ru username /rp password
    do not work

    so how can i pass
    python filename.py argument
    in quotes through runtime.getRuntime.exec();

  2. #2
    cool is offline Member
    Join Date
    Nov 2010
    Posts
    20
    Rep Power
    0

    Smile passing arument to runtime.getRuntime() method

    sorry for the post,


    problem resolved as i passed filename string as

    String filename = "\"python filename.py argument\"";

Similar Threads

  1. Why can I use Runtime.getRuntime() in Eclipse
    By ccie007 in forum New To Java
    Replies: 5
    Last Post: 10-18-2010, 06:48 PM
  2. problem with Runtime.getRuntime().exec when running java in .bat
    By Shayko in forum Threads and Synchronization
    Replies: 2
    Last Post: 01-27-2010, 07:46 PM
  3. help with Runtime.getRuntime().exec
    By collin389 in forum AWT / Swing
    Replies: 3
    Last Post: 11-09-2009, 04:22 AM
  4. Problem with Runtime.getRuntime().exec with Linux Commands
    By swapnilnawale in forum Threads and Synchronization
    Replies: 1
    Last Post: 09-23-2009, 10:23 PM
  5. grep on multiple files using Runtime.getRuntime().exec()
    By cprash.aggarwal in forum Advanced Java
    Replies: 3
    Last Post: 02-11-2009, 06:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •