Determining if session is a login session


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Determining if session is a login session
# 1  
Old 03-02-2010
Determining if session is a login session

Besides 'who am i' and 'tty' what commands could be used to determine if a session is interactive as compared to a web process or cron process. Any command should work with the common unix variants.
# 2  
Old 03-02-2010
maybe you can use : ps -fu username
# 3  
Old 03-03-2010
The command "who am i" and "tty" will both fail when run from cron because there is no terminal context.

This test will tell you whether you have terminal context. See "man test".

Code:
if [ -t 1 ]
then
        echo "I have terminal context"
else
        echo "I do not have terminal context"
fi

# 4  
Old 03-03-2010
The problem was that the program would not run if it was not run from a terminal session.
Read the manual, and found that the terminal can be spoofed with an environment variable. Problem solved.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

Difference between the desktop session and console session

what is the difference between desktop session and console session in solaris as i am wondering we use option -text for the former and -nowin for the later (1 Reply)
Discussion started by: kishanreddy
1 Replies

2. Shell Programming and Scripting

Record login session...

How to record my login session in a file named session.lst? (1 Reply)
Discussion started by: anupdas
1 Replies

3. Solaris

I am not able to login in gnome session and java session in Sun solaris 9& 10

I am not able to login in gnome session and java session in Sun solaris 9& 10 respectively through xmanager as a nis user, I am able to login in common desktop , but gnome session its not allowing , when I have given login credentials, its coming back to login screen, what shoul I do to allow nis... (0 Replies)
Discussion started by: durgaprasadr13
0 Replies

4. Shell Programming and Scripting

Hiding Directories on a Session by Session basis

Hi, Apologies if anyone has read my recent post on the same subject in the Linux forum, just thought actually the solution might more likely come from scripting. Essentially, I am trying to restrict access to directories based on the user's name AND their location on a session-by-session... (3 Replies)
Discussion started by: en7smb
3 Replies

5. Shell Programming and Scripting

Perl website login and session

Hi, I'm currently working on a perl website, and I would need a system where a few users can login into the administration side of the site. about 5-10 users maximum, all pretty simple. I was thinking of using an .htaccess file and a seperate admin folder on the server. I'm wondering if there... (2 Replies)
Discussion started by: LNC
2 Replies

6. UNIX for Dummies Questions & Answers

Need a Help Please- Login a reflectionX session but what you type is not what you get

Im having a problem using unix program client ReflectionX. as soon as i login to one session i type to change to any directory or type something but the problem is that what i type in is not what you get. ie i type: $cd ~/alejo (to change HOME DIRECTORY - alejo subdirectory but when i type it... (2 Replies)
Discussion started by: alexcol
2 Replies

7. Shell Programming and Scripting

sqlplus session being able to see unix variables session within a script

Hi there. How do I make the DB connection see the parameter variables passed to the unix script ? The code snippet below isn't working properly. sqlplus << EOF user1@db1/pass1 BEGIN PACKAGE1.perform_updates($1,$2,$3); END; EOF Thanks in advance, Abrahao. (2 Replies)
Discussion started by: 435 Gavea
2 Replies

8. UNIX for Advanced & Expert Users

Unix login session and Password

Hi All, I've login to Unix using login name guest and I'm working on it, I need another session to run some script hence tried to login but password invalid it says here my question is : Since I'm in working in one session can I set the password without knowing old password? is there any... (1 Reply)
Discussion started by: krishna
1 Replies

9. UNIX for Advanced & Expert Users

User login session

Having a problem on AIX 4.3.3 with the following error when more than 2 users try and sign onto the server. 3004-312 All available login sessions are in use. ???? (1 Reply)
Discussion started by: Docboyeee
1 Replies
Login or Register to Ask a Question