Assistance or Suggestion Needed


Forum: Other Help Topics
Topic: Assistance or Suggestion Needed
started by: apoc.feuer

Posted by apoc.feuer on June 14 2005,11:26
I'm not sure whether I'm posting it at the correct section or not though, moderators kindly shift this thread to a appropiate section if this thread is ir-relevant here. Ok, the story is this, I have a DSL machine that requires gain access to my Unix server. Right now I'm using telnet to gain access to it. But the process might be complicated to my end users the steps are as follows:

From terminal:
Step 1:telnet
Step 2:telnet>environ define TERM 'VT100' <---Because my Unix can only recongnise terminals that are set to VT100
Step 3:telnet>environ define TERMCOLOR 'VT100'
Step 4:telnet>open 192.XXX.X.XXX
Step 5: End user log in with their userid and password to gain access to our server

In order for me to minimise typo-error for end-users, I have created a shell script so that the above process is automated and end users only need to log in our Unix server to perform their daily tasks. This is where I got stuck...below is my shell script (Guess i simplify the entire script too much??!! I'm clueless here...)

My first shell script (test.sh)
==================
Line 1: telnet
Line 2: environ define TERM 'VT100'
Line 3: environ define TERMCOLOR 'VT100'
Line 4: open 192.XXX.X.XXX
==================

Error message
==========
./test.sh: line 2: environ: command not found
./test.sh: line 3: environ: command not found
==========

It's seems that my script is unable to carry out the correct command in telnet environment. ( I have also tried to set the terminal type before I use telnet but it's of no use, my unix machine is unable to recongise my DSL terminal type) Is it possible to let my script 'know' that it's in the telnet environment and it must set the terminal type to VT100 in order for it to gain access to our unix server? Any advise/suggestions would be greatly appreciated. (Anyway this is my first time doing shell script)

Posted by mikshaw on June 14 2005,13:28
The 'environ' command is specific to Telnet, and therefore will not be understood by your shell (probably Bash).  You'll need to pass the commands to telnet rather than trying to have the shell execute the commands.
I don't know much about Telnet, but apparently some variables can be taken from the user's environment.  For example, if you want to set the terminal type you'd export that variable from a shell and then start telnet from the same shell (not sure if TERMCOLOR will work this way):
export TERM=vt100
export TERMCOLOR=vt100
exec telnet 192.XXX.X.XXX

or:
TERM=vt100 telnet 192.XXX.X.XXX

I can't guarantee this will work, but this is what i got from the man page.
< http://linuxmafia.com/coffeenet/FAQ/telnet.html >

Posted by friedgold on June 14 2005,16:02
How about

Line 1: telnet << EOF
Line 2: environ define TERM 'VT100'
Line 3: environ define TERMCOLOR 'VT100'
Line 4: open 192.XXX.X.XXX
Line 5: EOF

Posted by apoc.feuer on June 15 2005,00:36
Sorry to reply late, thanks guys let me try both of the suggestions out and keep you guys updated. Thank you for sharing... :laugh:
Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.