Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

java ping problem

  • 23-03-2006 6:22pm
    #1
    Closed Accounts Posts: 73 ✭✭


    Any one have any idea why this wont work??What its meant to do is put the ping command together and then inserts it into a command window and executes the command.Its putting the ping command together properly but nothing seems to be saving in the textfile "c:\ping.txt".Any help will be greatly appreciated.

    public class Ping{

    Ping(String Ip,String Ip1){
    StringBuffer PingCommand = new StringBuffer("ping -n 1 ");
    String PingText = " > c:\\ping.txt";

    PingCommand.insert(PingCommand.length(),Ip);
    PingCommand.insert(PingCommand.length(),PingText);
    System.out.println(PingCommand);
    try{

    Process PingProcess = Runtime.getRuntime().exec(PingCommand.toString());
    }
    catch(Exception IO){
    }

    }
    public static void main(String[] args){
    Ping p = new Ping("192.168.1.1","");
    }
    }


Comments

  • Registered Users, Registered Users 2 Posts: 2,013 ✭✭✭lynchie


    Runtime.getRuntime().exec() does not execute within a command shell like a standard windows cmd.exe. Have a look here on how it should be done


  • Closed Accounts Posts: 73 ✭✭Nocturnal


    ok but i used the exact same thing before except with an nmap command and thats working fine,is there some difference between an nmap command and a ping command exectuting even though ping.exe and nmap.exe both are in the same directory,what i mean is does cmd.exe have to execute before ping.exe executes?


Advertisement