Operating System - HP-UX
1833850 Members
2267 Online
110063 Solutions
New Discussion

Re: Getting an ID reply from a terminal

 
SOLVED
Go to solution
Bolek Mynarski
Frequent Advisor

Getting an ID reply from a terminal

I'm not sure how to put it. We want to include into our global profile a little script that will prompt user's terminal to identify itself and upon terminal's request, greet the user with something like:

"You have logged on using VT100, or VT200, or Reflections and so on."

What we have so far is this:

echo "033[0;1234c" which prompts the terminal for ID and we know that it answers back (we have tested it on a command line).

Now, how do I capture the response and send a message back based on it?

I tried redirecting it to the file, grepping and so on but this does not work. If I try to cat that file, it simply responds back with a beep.

Any ideas?

Thanks.
It'snever too late to learn new things...
11 REPLIES 11
Victor BERRIDGE
Honored Contributor

Re: Getting an ID reply from a terminal

Why not simply echo $TERM ?
in your .profile
Victor BERRIDGE
Honored Contributor

Re: Getting an ID reply from a terminal

This is what I do for root connections, may it inspire you:
LOG='who am i -R'
ME=$LOGNAME
(date;echo $ME;$LOG)|xargs >>/var/adm/root/.log
export ME
John Palmer
Honored Contributor

Re: Getting an ID reply from a terminal

Have you tried
echo .....
read REPLY (or any variable name)

The response from the terminal should then be in $REPLY
Tracey
Trusted Contributor

Re: Getting an ID reply from a terminal

I use:

TERM=`ttytype`
export TERM
echo 'Your Term is:' $TERM
Bolek Mynarski
Frequent Advisor

Re: Getting an ID reply from a terminal

I did not express myself clearly. O.K.
When I'm logged on using "Reflections" terminal, my term can be set to vt200 or whatever, and true, when I type echo $TERM, it will display vt200. However, what I want to get is this info:

when I type echo "033[0;1234c", it queries the terminal client which responds back with:

[bmynars@optivity /home/bmynars/bin]$ W02-600L333333
sh: W02-600L333333: not found.

It looks like it starts a subprocess. What I want to capture is W02-600L333333 (not type of term which would be vt200.

That's what I can't do.
It'snever too late to learn new things...
Alan Riggs
Honored Contributor

Re: Getting an ID reply from a terminal

Have you tried:

CONNECTION=`echo "033[0;1234c"` (note: backtics not quotes)

echo "Your connection type is $CONNECTION"
Bolek Mynarski
Frequent Advisor

Re: Getting an ID reply from a terminal

Hi Alan:

"Have you tried:

CONNECTION=`echo "033[0;1234c"` (note: backtics not quotes)

echo "Your connection type is $CONNECTION"
"

If you run "033[0;1234c" only, it will simply echo back exactly the same thing. So, if you put ""033[0;1234c" then you get response back but we're back to square one. It looks like this command opens a subshell and tries to run there. How do I capture it?
It'snever too late to learn new things...
Bolek Mynarski
Frequent Advisor

Re: Getting an ID reply from a terminal

I meant 033[0;1234c
It'snever too late to learn new things...
Bolek Mynarski
Frequent Advisor

Re: Getting an ID reply from a terminal

I noticed that my '' slashes are missing. So, there is a "backslash" in front of "033[0;1234c".
It'snever too late to learn new things...
John Palmer
Honored Contributor
Solution

Re: Getting an ID reply from a terminal

Your echo statement causes the terminal emulation software to respond with configuration info (as if you had typed it in).

Simply using the 'read' command allows you to get the reply into a shell variable. See my response above.
Bolek Mynarski
Frequent Advisor

Re: Getting an ID reply from a terminal

Thanks John. I don't know what I was thinking when I as trying to pipe read. :-)
That solved my problem.
It'snever too late to learn new things...