Finding just unix user


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Finding just unix user
# 1  
Old 09-23-2010
Finding just unix user

I need to check for username that we are logged in.There are a lot of unix users and proceed according to that
i.e

find unix user

if [ user = x]

then echo "x"
elif [ user = y]

then echo "y'

fi
fi

Now I dont know how to find and put user in if condition
# 2  
Old 09-23-2010
This will print a list of users logged in:
Code:
w -h | awk '{print $1}'

To get you started.
# 3  
Old 09-23-2010
How do you put that in that user in if condition and check
# 4  
Old 09-23-2010
Code:
MYUSERS=`w -h | awk '{print $1}'`
for user in ${MYUSERS}
do
        if [ $user = "khagan" ]; then
                echo "Username ${user} is logged in."
        else
                echo "Not who your looking for"
        fi
done

# 5  
Old 09-25-2010
What you have is working good. But I need the way to find users who logged in
suppose there are 4 users
Tom, Mark John, Jean

If I login as Mark do one process or else If u login as John do Process1

I dont want list of users present. But I want users logged in as
# 6  
Old 09-25-2010
- Who's going to check if "Mark" or "John" has logged in ?
- Who runs "process1" or "process2" when "Mark" or "John" have logged in ?

tyler_durden
# 7  
Old 09-26-2010
I need a script which checks
If you login as mark do process1
else
if you login as Tom do process2
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding AIX user accounts expired or locked

// AIX 6.1 In need of finding which AIX user accounts will be expired and are locked. I have placed the following parameters under /etc/security/user... (1 Reply)
Discussion started by: Daniel Gate
1 Replies

2. UNIX for Advanced & Expert Users

Finding a Particular Pattern In UNIX

Hi, Suppose I have a file with many lines as follows. Now I want to find the following questions from the file through shell script or commands. My name is XYZ. XYZ works for GHT and XYZ is part of PES. GHT is a good organization. XYZ knows swimming. XYZ is also very keen in reading. XYZ is a... (2 Replies)
Discussion started by: sktkpl
2 Replies

3. UNIX for Advanced & Expert Users

Finding user accounts not accessed for a specific number of days

Hi all, Recently I came across a challenge of finding the user accounts lying around on servers and not being used so much. Our client has hundreds of AIX, RedHat, and Solaris servers. For AIX, I have made a script which uses lsuser and a little bit of sed and awk to show the user accounts... (7 Replies)
Discussion started by: admin_xor
7 Replies

4. HP-UX

finding free memory as a non-root user

All, I have a software application that requires to find the free memory on the machine. It should work in a hpux Out of the box - in other words, it should use the basic OS commands which are available on every HP-UX machine like top, vmstat and doesn't require the user to purchase 3rd... (2 Replies)
Discussion started by: sunny8107
2 Replies

5. Shell Programming and Scripting

help for shell script of finding shortest substring from given string by user

please give me proper solution for finding a shortest substring from given string if string itself and first char and last char of that substr are also given by user if S="dpoaoqooroo" and FC="o" and LC="o",then shortest substr is "oo" and rest of the string is "dpoaoqroo" i have code but it is... (1 Reply)
Discussion started by: pankajd
1 Replies

6. UNIX for Dummies Questions & Answers

finding out user name from an ip

if i know the ip of a computer on the subnet, it it possible to findout the username of the user that is using that system? (4 Replies)
Discussion started by: purest
4 Replies

7. Shell Programming and Scripting

Finding The Number Of Programs That A Given User Running On A TERMINAL

How To Find The Number Of Programs That A User Running ON A GIVEN TERMINAL (4 Replies)
Discussion started by: venkata.ganesh
4 Replies

8. Shell Programming and Scripting

Finding the group to which a user belongs

Is there any command to find to which group u ser belongs (3 Replies)
Discussion started by: radhika03
3 Replies

9. UNIX for Dummies Questions & Answers

Finding Printer in unix

I am trying to find the list of printers(names) in the network from unix server. can anybody help me . I need the command. Thanks in advance. :) (2 Replies)
Discussion started by: vijisenthil
2 Replies

10. UNIX for Dummies Questions & Answers

finding directories in UNIX

I am accessing a UNIX server via FTP. I want to retieve a file in a directory. What is the UNIX command that I need to view and retrieve files from a directory? (1 Reply)
Discussion started by: yodaddy
1 Replies
Login or Register to Ask a Question