Hi Bill,

Open a socket to the device, send a command and read from the same socket with a message, probably using lf, cr or crlf as line ending. Never close the socket, unless you want to log out.

Below follows a very simple example, which may work only in theory but which shows the basics of a telnet client.

// button script
on mouseUp
  put "192.168.1.99:23" into myDevSock
  set the cSock of fld "Command" to myDevSock
  open socket myDevSock
  write "hello" to socket myDevSock // whatever command is appropriate
  read from socket myDevSock until cr with msg "gotReply"
end mouseUp

// card script
on gotReply theSock,theMsg
  put theMsg into fld "Terminal"
  select text of fld "Command"
end gotReply

// card script
on closeStackRequest
  answer "Do you want to close the connection?" with "Yes" or "No"
  if it is "Yes" then pass closeStackRequest
end closeStackRequest

// field "Command"
on returnInField
  put the cSock of me into myDevSock
  write the text of me to socket myDevSock
  read from socket myDevSock until cr with msg "gotReply"
on returnInField

I haven't tested this, but it should work. You need a stack with a field "Terminal", a field "Command" and a button. Put the scripts into their respective places and change the IP and port numbers. If necessary, change cr into crlf for example. You might need to escape some characters before sending them to the telnet server; check the documentation of the server.

You can find a complete, tested and working telnet *server* script at http://qurl.tk/9s .

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer

We have updated TwistAWord. Download TwistAWord 1.1 at http://www.twistaword.net

Op 29 apr 2010, om 08:30 heeft Bill Vlahos het volgende geschreven:

I want to script a session to a network device using telnet in Rev.

The goal is to log into a telnet device like a firewall and issue a command. Are there any examples on how to do this?

I will want to log into a firewall via telnet in Rev with a name and password in a session and issue a "reload" command on the device and then respond to the confirmation Yes or No.

The idea is that I'll use the network and server monitor software (Whistle Blower) to monitor the health of a firewall. If there is a problem with the firewall Whistle Blower will open my compiled application (to protect a login name and password) and it will issue a command to reboot the target server.

Bill Vlahos

_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to