Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
 

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: Assistance or Suggestion Needed, Shell Script Anyone???< Next Oldest | Next Newest >
apoc.feuer Offline





Group: Members
Posts: 4
Joined: June 2005
Posted: June 14 2005,11:26 QUOTE

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)
Back to top
Profile PM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: June 14 2005,13:28 QUOTE

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


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
friedgold Offline





Group: Members
Posts: 122
Joined: Mar. 2005
Posted: June 14 2005,16:02 QUOTE

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
Back to top
Profile PM 
apoc.feuer Offline





Group: Members
Posts: 4
Joined: June 2005
Posted: June 15 2005,00:36 QUOTE

Sorry to reply late, thanks guys let me try both of the suggestions out and keep you guys updated. Thank you for sharing... :laugh:
Back to top
Profile PM 
3 replies since June 14 2005,11:26 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

 
reply to topic new topic new poll
Quick Reply: Assistance or Suggestion Needed

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code