Using Netlinx NI-700 to telnet into a Mac and Launch Facetime.

leif.sehnleif.sehn Junior MemberPosts: 2
Hello All,

Recently we have been trying to use a NI-700 to login to a MacMini using telnet to launch Facetime.

We have successfully been able to do this through the command line on a mac or pc either using SSH or the Telnet protocols to make sure it was all setup properly, permission wise, on the macmini.

On the programming side we can get the ni-700 to initiate the connection. The part I am getting hung up on is sending the login and password.

Has anyone been able to make this work?

I think I am pretty close to getting this going, any help would be appreciated.

My code is below:

PROGRAM_NAME='SSHConnection'
DEFINE_DEVICE

(*** NetLinx ***)
dvTELNET = 0:5:0
dvButton = 10001:1:0

(***********************************************************)
(* CONSTANT DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_CONSTANT

(* IP *)
IP_TCP = 1
IP_UDP = 2
nTELNET_PORT = 23

(***********************************************************)
(* TYPE DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_TYPE

(***********************************************************)
(* VARIABLE DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_VARIABLE

(* INFO *)
CHAR strTELNET_BUFFER[1000]
SLONG slRESULT

(***********************************************************)
(* SUBROUTINE DEFINITIONS GO BELOW *)
(***********************************************************)

(**************************************)
(* CALL NAME: GET_TELNET_PARAMETER *)
(* FUNCTION: GET PARAMETER FROM STR *)
(* PARAMS: BUFFER - IN *)
(* RETURN: PARAMETER *)
(**************************************)
DEFINE_FUNCTION CHAR[100] GET_TELNET_PARAMETER (CHAR strDATA[])
STACK_VAR
CHAR chCHAR
CHAR strPARAM[100]
{
(* CLEAN UP AND SHORT CIRCUIT *)
strPARAM = ""
IF (LENGTH_STRING(strDATA) = 0)
RETURN strPARAM;

(* KILL SPACES *)
WHILE (strDATA[1] = $20 && LENGTH_STRING(strDATA))
chCHAR = GET_BUFFER_CHAR(strDATA)

(* GET UP UNTIL CR *)
WHILE (strDATA[1] <> $0D && LENGTH_STRING(strPARAM) < 100)
strPARAM = "strPARAM,GET_BUFFER_CHAR(strDATA)"

(* DONE *)
RETURN strPARAM;
}

(***********************************************************)
(* STARTUP CODE GOES BELOW *)
(***********************************************************)
DEFINE_START

(* BUFFERS *)
CREATE_BUFFER dvTELNET,strTELNET_BUFFER

(***********************************************************)
(* EVENT PROCESSING ROUTINES BELOW *)
(***********************************************************)
DEFINE_EVENT

(***************************)
(*** TELNET MESSAGES *******)
(***************************)
BUTTON_EVENT[dvButton,1]
{
PUSH:
{
SEND_STRING dvTELNET,"'open FaceTime://',13,10"

}
}
BUTTON_EVENT[dvButton,2]
{
PUSH:
{
SEND_STRING dvTELNET,"'',13,10"
}
}

BUTTON_EVENT[dvButton,3]
{
PUSH:
{
IP_CLIENT_CLOSE (dvTELNET.PORT)
}
}

BUTTON_EVENT[dvButton,4]
{
PUSH:
{
SEND_STRING dvTELNET,"'username',13,10"
wait 20
{
SEND_STRING dvTELNET,"'password',13,10"
}
}
}
DATA_EVENT[dvTELNET]
{
ONERROR:
{
SEND_STRING 0,"'TELNET EVENT: ERROR(',ITOA(DATA.NUMBER)"
strTELNET_BUFFER = ""
}
ONLINE:
{
SEND_STRING 0,'TELNET EVENT: ONLINE'
strTELNET_BUFFER = ""

}
OFFLINE:
{
SEND_STRING 0,'TELNET EVENT: OFFLINE'
strTELNET_BUFFER = ""
}
STRING:
{
(* VARS *)
STACK_VAR
CHAR strTEMP[100]
LONG lPOS
SEND_STRING 0,Data.TEXT
(* DEBUG *)
SEND_STRING 0,'TELNET EVENT: INFO'

strTEMP = data.text

}
}

(***********************************************************)
(* THE ACTUAL PROGRAM GOES BELOW *)
(***********************************************************)
DEFINE_PROGRAM

WAIT 200
{
slRESULT = IP_CLIENT_OPEN (dvTELNET.PORT,'192.168.0.10',nTELNET_PORT,IP_TCP)
IF (slRESULT < 0)
SEND_STRING 0,"'IP_CLIENT_OPEN ERROR: ',ITOA(slRESULT)"
}

(***********************************************************)
(* END OF PROGRAM *)
(* DO NOT PUT ANY CODE BELOW THIS COMMENT *)
(***********************************************************)

Comments

  • leif.sehnleif.sehn Junior Member Posts: 2
    Thanks everyone who looked at this, but I managed to figure it out.

    If anyone needs the code let me know and I can post my solution.
  • kbartlomekbartlome Junior Member Posts: 1
    i know it was a long time ago...but can you post?

    do you remember that far back?

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file