i have done following java program using net send.it says message sent successfully, couldn't see message.here code
import java.io.*; import java.net.*; class sample{ public static void main(string args[]) throws exception { try{ runtime r=runtime.getruntime(); process p=null; string msg; string trip; string cmd; bufferedreader br=new bufferedreader(new inputstreamreader(system.in)); system.out.println("enter ip address of remote host"); trip=br.readline(); system.out.println("enter msg sent remote host"); msg=br.readline(); cmd="net send"+trip+""+msg; p=r.exec(cmd); thread.sleep(1000); system.out.println("msg soc sent sysytem"); }catch(exception e){ system.out.println(e); } } }
you need more spaces in string:
cmd="net send "+trip+" "+msg;
otherwise ipaddress (or whatever string given) directly after send
in resulting string.
Comments
Post a Comment