KORN Shell - Spawn new shell with commands

I want to be able to run a script on one server, that will spawn another shell which runs some commands on another server..

I have seen some code that may help - but I cant get it working as below:

spawn /usr/bin/ksh
send "telnet x <port_no>\r"
expect "Enter command: "
send "LOGIN:x:x; \r"
expect "Enter command:"
send "LOGOUT; \r"
close

but this errors - I may be missing code etc, I honestly dont know. Can anyone help me? Or is there another way to do this?
I dont want to execute a script on the other server, I want to log on to it and type some commands, get the response and log off... Please note I log on to server on a specific port - this is not telnet.

Any help would be appreciated.

Do you have 'expect' installed and have it defined as the interpreter? The following should be at the top of your script (path may vary).

#!/usr/local/bin/expect

Cheers,

Keith

Doh! Should have seen that...

I have expect installed - just didnt have it as the interpreter in the script...
Thanks!!!