Results 1 to 3 of 3
  1. #1
    cooljava is offline Member
    Join Date
    Aug 2014
    Posts
    1
    Rep Power
    0

    Default Can this possibly done?

    Hello,

    Say you have a program called "whatever.exe". Basically, what this program does is to run batch commands, "dir" and "cd".
    if you run this "whatever.exe", the output will be something like...
    ------
    dir...
    blahblah. list of directories..
    cd blahblah..
    ------

    you want to run this "whatever.exe" from java application..
    So like..

    Runtime rt = Runtime.getRuntime();
    Process pr = rt.exec("whatever.exe");
    BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    String line = null;
    while( (line = input.readLine() ) != null) {
    System.out.println(line);
    }

    cool...done..you are going to see the output result for the whatever.exe at your console...
    However, the thing I want is that..somehow..I want to intercept the cd command and change the parameter on the fly...
    For example, say, this whatever.exe runs "cd C:\ABCD" internally, but somehow I want to change this cd command like "cd C:\EFGH" to run by my Java application..
    Well..obviously, you don't have a source code for "whatever.exe".

    I was thinking if we somehow..somehow...could manipulate some stream...this could be done....but I really don't think though..
    Anyway, any idea would be appreciated.

    Thanks,
    Last edited by cooljava; 08-09-2014 at 12:36 AM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,025
    Rep Power
    6

    Default Re: Can this possibly done?

    What use would that be unless you already understand the purpose of "whatever.exe?" Why don't you explain
    what you are actually trying to accomplish? Then there might be an alternate way of achieving the same thing.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

Similar Threads

  1. Math.abs possibly returning a negative number
    By jdodle in forum New To Java
    Replies: 4
    Last Post: 10-06-2013, 03:31 AM
  2. Replies: 1
    Last Post: 08-18-2010, 12:53 PM
  3. this keyword possibly buggy with scopes ?
    By Coral in forum Advanced Java
    Replies: 4
    Last Post: 02-02-2010, 01:50 PM
  4. Replies: 6
    Last Post: 04-10-2009, 03:08 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
  •