Page 1 of 1

Interactive launch or open process?

Posted: Sun Apr 15, 2007 10:08 am
by nkrontir
Hi.

I was wondering if there was a way to make an open process interactive, or better said be able to enter more input to that command line or shell before the close process, something like a rudimentary expect.
For instance, say that someone wants to launch a telnet command through a revolution interface so that their username and password would have to be entered after the launch of the command.
I guess there would be a button with more or less this code but i have no clue how to implement the "put this in that shell":

Code: Select all

on mouseUp
  open process "telnet "&server_ip
  read from process "telnet "&server_ip for 10 in 10 seconds
  put it into some_variable
  if matchtext(some_variable,".*username.*") then ???????
  if matchtext(some_variable,".*password.*") then ???????
  close process "telnet "&server_ip
end mouseUp

Posted: Sun Apr 15, 2007 4:45 pm
by Janschenkel
Where you can 'read', you can usually 'write' - look at the 'write to process' command to send keystrokes to the stdIn of the previously opened process.

Code: Select all

on mouseUp
  put "telnet" && server_ip into tProcess
  open process tProcess 
  read from process tProcess for 10 in 10 seconds 
  put it into some_variable 
  if matchtext(some_variable,".*username.*") then
    write tUserName & return to process tProcess
  else
    close process tProcess
    exit mouseUp
  end if
  -- do whatever else is part of the communication
  -- ...
  -- don't forget to close the process when you're done
  close process tProcess 
end mouseUp
Oh, and if you're looking to do telnet communication, you may be interested in the 'open socket', 'read from socket', 'write to socket' and 'close socket' commands - no need to go through a command line application to communicate over TCP sockets.

Hope this helped,

Jan Schenkel.