How can I tell whether I am logging in on console inside .login?

How can I tell whether I am logging in on console inside .login?

Post by Andrew J Mill » Fri, 19 Mar 1993 13:50:37



When I log in on the sun, 3 windows are opened. Each of these windows runs
the .login script, but certain commands (e.g. xsetbg) only need to run once.
In addition, when I log in from a remote location, I don't need to run these
commands.
Is there a simple way of telling how I am connected?
How would I implement it within a script, if it isn't totally self evident.
(Within my .login, I run a short shell script in the background which checks
whos logged in, gets the weather, etc.)
Thanx much in advance
Wonder Midget
 
 
 

How can I tell whether I am logging in on console inside .login?

Post by -Drago » Fri, 19 Mar 1993 23:05:35



:
: When I log in on the sun, 3 windows are opened. Each of these windows runs
: the .login script, but certain commands (e.g. xsetbg) only need to run once.
: In addition, when I log in from a remote location, I don't need to run these
: commands.
: Is there a simple way of telling how I am connected?
: How would I implement it within a script, if it isn't totally self evident.
: (Within my .login, I run a short shell script in the background which checks
: whos logged in, gets the weather, etc.)
: Thanx much in advance
: Wonder Midget

Try this:

if ("`tty`" == "/dev/console") then
# console dependent instructions
endif

(The coding of the 'if' instruction based upon assumption you are using
[t]csh)

                                * - * - *

Paul-Joseph "Dragon" de Werk        |        Carpe diem.
Department of Computer Science      | "First things first, but not
California State University, Fresno |  necessarily in that order."

HELLO!  I'm a .signature virus! Join in and copy me into yours!

 
 
 

1. How can my script tell if I am in the console?

I use zgv to display images when I am in the console (ttyv0).
This won't work if I am in another ttyv.

I want to write a script to use zgv to display a picture if I
am in the console and xzgv if I am in X.  I want it to bail
otherwise (i.e. if I am in another ttyv).

I want this script (showpics) to be mapped to image/* in
.mailcap and in lynx.

I know I can test $DISPLAY to see if I am in X (it isn't set
if I am in a ttyv.

However, tty doesn't tell me if lynx or the mail program I am
using is running in ttyv0.

Here is my attempt at the script:

#!/bin/sh
#show-pics

ISCONSOLE=`tty`

if [ "$DISPLAY" = "" ];
then
#if [ "$ISCONSOLE" = "/dev/ttyv0" ];
#then
zgv $1
else
echo not in console
fi
else
xzvg $1
fi

#end

This works fine from the command line.  But 'tty' returns
"not a tty" when this script is invoked by lynx, etc.  I
gather this doesn't work because STANDARD INPUT is then
something else.  What I need to know is whether lynx or
whatever is running in the console so that zgv will
succeed.  How can my script tell?

--

 It's important for us to explain to our nation that life is important. It's
 not only life of babies, but it's life of children living in, you know, the
 dark dungeons of the Internet.--G.W. Bush, Arlington Heights, Ill.,10/24/00

2. lsof and the FD column

3. Need HELP to Log User Log-ins form the internet

4. AIM File Transfers and iptables

5. logging - "secure" logs don't tell me who is logging in?

6. ghostscript 3.51

7. Solaris 2.4 Can't tell when logins are not on the console

8. mail &news ???????

9. How to tell whether a hardware RAID controller is installed?

10. In solaris 8 how to tell whether the network interface is in promiscuous mode

11. Gadget to tell me whether PPP is up

12. How to tell whether there is a server monitoring an AF_UNIX socket ?

13. how to tell whether running 32-bit or 64-bit