Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java app. sends "CTRL+D" through output stream in linux os.

 
Rakesh Kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi dear all,
I ahve a java application which will execute linux commands through java code.But I have to send "CTRL+D" key to close one session in linux.My doubt is how we can hard code and send this CTRL+D code using java code?What is teh string for that ?

rakesh
 
Henry Wong
author
Marshal
Pie
Posts: 21504
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rakesh Kumar wrote:Hi dear all,
I ahve a java application which will execute linux commands through java code.But I have to send "CTRL+D" key to close one session in linux.My doubt is how we can hard code and send this CTRL+D code using java code?What is teh string for that ?



A control-D is a character with an ASCII value of 4.

Henry
 
Rakesh Kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friend , I have api to send linux connad in my java application as below

telnet.transpose("ls -lrt");
_response = telnet.expect(promptArr);

telnet.transpose("Ctrl+d");------------------------------------->?
_response = telnet.expect(promptArr);


'transpose ' methode we have to pass the linux command , then it will execute it.But my problem is whta is teh string for 'CTRL+D' to pass as i made red color.
Please help
Rakesh
 
Henry Wong
author
Marshal
Pie
Posts: 21504
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you know how to create a character with the value of 4? Do you know how to append that character to your string?


try...



Henry
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rakesh Kumar wrote:urgent help required

Please EaseUp
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic