Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can I run telnet thru a java program?

 
vikram kulkarni
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can I run telnet thru a java program?
i need to login to a unix server and run a script. this script would run some unix commands (e.g date, who etc.) and redirect this to a file on the unix server. my program should then be able to read this file.
thanks
vicky
 
Dave Smith
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would imagine this would work. You would need to connect via a URLConnection prehaps, then wait until you read the login information from the socket. Then write the stuff to login, and basically control the whole session as if you were typing it yourself.
BTW, you can use the "cat" command to put the contents of the file you have just written to the socket.
Hope this helps.
Dave Smith
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic