Bash scripting multiple condidtions
Greetings I wonder who can solve this riddle, :) he he What I am trying to establish is whether or not a terminal is a valid terminal, I have constructed some test, the terminal must be using linux terminal emulation, and must be run on a valid linux shell. Let me explain, I am scripting in dialog for good looks, nothing more .. He he The reason is to get users to run my script at the server or from an emulator that works properly in linux. Now most of our clients use hotkey, and dialog does not work via hotkey. So if the user logged in and got a tty? shell, it would be first class. The problem is it also works fine from kde konsole if I ssh or telnet into the server. But not from Hotkey or from a thin client because our third party primary program uses ansi. So all our hotkey machines and thinclients are to ansi. When you telnet or ssh you are given a pseudo terminal, and $TERM - linux, but when you hotkey or use a thin client you also get a pseudo terminal but with ansi. and then dialog is unusable. I have treid everything to get the hotkey and thinclients to emulate linux correctly. in the profiles and in the script, but nothing works properly. so I constructed a test (below ) but bash ignores the third test... it should read if term is not linux and is not a tty? or pts? then (run text version or exit or something ... I haven't decided yet!) STERM=`tset -q` TTERM=`tty` if [[ ! $STERM == linux && $TTERM != /dev/tty? || $TTERM != /dev/pts/? ]]; then Ideas would be greatly appreciated TIA -- -- Chadley Wilson Production Line Superintendant Pinnacle Micro Manufacturers of Proline Computers ==================================== Exercise freedom, Use LINUX =====================================
On 10/6/05, Chadley Wilson
Greetings
I wonder who can solve this riddle, :) he he
[snipped lot's of useful introductory information]
it should read if term is not linux and is not a tty? or pts? then (run text version or exit or something ... I haven't decided yet!)
STERM=`tset -q` TTERM=`tty`
if [[ ! $STERM == linux && $TTERM != /dev/tty? || $TTERM != /dev/pts/? ]]; then
I am not a bash guru, but since the == and || operators have equal precedence the last evaluation is ignored because the first two short circuits the last one (as can be seen in the C programming language). Try this: if [[ ! $STERM == linux && ($TTERM != /dev/tty? || $TTERM != /dev/pts/?) ]]; I usually don't do shell scripting so I cannot comment on the overall approach, but I hope this helps a bit. Cheers \Steve
participants (2)
-
Chadley Wilson
-
Steve Graegert