Interactive launch or open process?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
nkrontir
Posts: 15
Joined: Wed Apr 12, 2006 3:24 am

Interactive launch or open process?

Post by nkrontir » Sun Apr 15, 2007 10:08 am

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

Janschenkel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 977
Joined: Sat Apr 08, 2006 7:47 am
Location: Aalst, Belgium
Contact:

Post by Janschenkel » Sun Apr 15, 2007 4:45 pm

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.
Quartam Reports & PDF Library for LiveCode
www.quartam.com

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”