Shell script to check whether user has logged in or not, Programming Languages

Assignment Help:

W.A.S.S to check whether user has logged in or not.

 

Program

 

# W.A.S.S to check whether user has logged in or not.

 

echo "Enter the user name:"

read usr

flag=0

for w in ` who | tr -s " " | cut -d " " -f1`

do

if test $usr = $w

then

echo "User is logged in.."

flag=1

fi

done

 

if test $flag = 0

then

            echo "User is Not logged in.."

fi

 

Output:

 

Enter the user name:

root

User is logged in..

 

Enter the user name:

narenda

             User is Not logged in


Related Discussions:- Shell script to check whether user has logged in or not

Explain the goto statement - computer programming, Explain the Goto Stateme...

Explain the Goto Statement - Computer Programming? The goto statement is employed to alter the normal sequence of program execution by transferring control to some other part o

Differentiate between high level and low level languages, The languages use...

The languages used in the module are of a type known as high-level languages. There is another set of languages known as low-level languages. (a) Differentiate between high-leve

Develop a socket program in unix, Develop a socket program in UNIX/Linux th...

Develop a socket program in UNIX/Linux that uses (i) TCP as the transport protocol and  (ii) UDP as the transport protocol for transferring  a short message between a client and  s

1 real and 2 complex eigenvalues, 1 Real and 2 Complex Eigenvalues    ...

1 Real and 2 Complex Eigenvalues    From the real eigenvalue/vector pair, l 1 and ?h 1 e l1 t ?h 1 We find the other two solutions in identical manner which we did

Genetic algorithm, I need help I want to implement the Genetic Algorithm f...

I need help I want to implement the Genetic Algorithm for Shortest path Kindly Help me I will be thankful to you

Shell script to print left traingle, Normal 0 false false f...

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

Create a linux shell, Create a linux shell (in other words, write a C/C++ p...

Create a linux shell (in other words, write a C/C++ program) that will recursively prompt for input from the user. The shell should prompt as yourRollNumber-currentDirector

How do you find the complexity of an algorithm, How do you get the complexi...

How do you get the complexity of an algorithm? What is the relation b/w the time & space complexities of an algorithm? Justify your answer with an example.

Program to records name-bounty and difficulty for ten target, You have been...

You have been employed by a bounty hunter to create hit list (yes... you better do this right). Create a Hit List program that can records the name, bounty, and difficulty for ten

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd