LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-11-2008, 02:04 PM   #1
dale504
LQ Newbie
 
Registered: Jan 2008
Location: IL
Distribution: f8
Posts: 29

Rep: Reputation: 15
how do i wright a script called "checking"


ok i would like it to give me these options:

1 display a prompt asking for a user name
2 read the user input
3 finger the user
4 display any results from the who command about this user only
5 display any results from the ps command about this user only

can any one help?
thanks.......
 
Old 02-11-2008, 02:12 PM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Could this be homework? If you answered yes, please state that it is a homework, and don't expect full ready-to-use answers.

What have you done so far, and where did you encounter problems you couldn't overcome by thinking yourself, reading books and/or online resources, or asking your teacher/tutor (who should be the primary person to ask questions) if this was homework?
 
Old 02-11-2008, 02:31 PM   #3
dale504
LQ Newbie
 
Registered: Jan 2008
Location: IL
Distribution: f8
Posts: 29

Original Poster
Rep: Reputation: 15
OK so it is!
now then to display a prompt asking for a user name:
some this like this:

#!/bin/bash
echo "username"
Read answer
if [$answer = dale];
then echo "hello dale"
else
echo "Invalid usre!!"

this seem ok or not ????

dale
 
Old 02-11-2008, 02:46 PM   #4
{David}
LQ Newbie
 
Registered: Feb 2008
Location: Hannover
Distribution: Debian, SuSe
Posts: 3

Rep: Reputation: Disabled
Hi!
You should really try and read a Book or search on the internet before you ask.
This is not meant bad but if you just get the answer you may not learn something from it.
I searched via google and found this:

http://www.freeos.com/guides/lsst/

http://www.tech-faq.com/lang/de/unix...utorials.shtml

Hopefully this will help...
 
Old 02-11-2008, 02:58 PM   #5
LinuxCrayon
Member
 
Registered: Nov 2007
Location: Georgia, USA
Distribution: FreeBSD
Posts: 274

Rep: Reputation: 31
Quote:
Originally Posted by dale504 View Post
OK so it is!
now then to display a prompt asking for a user name:
some this like this:

#!/bin/bash
echo "username"
Read answer
if [$answer = dale];
then echo "hello dale"
else
echo "Invalid usre!!"

this seem ok or not ????

dale
Please use code tags.

Also, the problem with that is it checks only to see if one particular user exists. But what if you have 20 users. Are you going to write an if-else for all 20? What about 50? 100? You get the idea. The problem is that you're having to manually insert each users' name on the system to check for his existence which is problematic for a number of reasons.
 
Old 02-11-2008, 03:08 PM   #6
dale504
LQ Newbie
 
Registered: Jan 2008
Location: IL
Distribution: f8
Posts: 29

Original Poster
Rep: Reputation: 15
now that was helpfull!!!!!!
but i have no idea where to start with the last two items give me a hint!

thanks....
 
Old 02-11-2008, 03:29 PM   #7
LinuxCrayon
Member
 
Registered: Nov 2007
Location: Georgia, USA
Distribution: FreeBSD
Posts: 274

Rep: Reputation: 31
I'm no BASH guru. I'm not even that good at it, really. But I do understand the concepts of programming and I generally like to think I know how to think like one. Probably a bad sign...

Anyway.

You should use Google to figure out where a list of users is kept. Additionally, there's a how-to under the network tutorials of this site that would show you how to list all current users. I'll leave it up to you to find.

Once you know how to list the users, it's a matter of writing some code that will go through that list and try to match it with the user's input. Seems like a for loop would work, but again I'm no BASH guy.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 7 12-19-2015 02:03 AM
./configure script hangs at "checking for ICMP ping syntax..."l khilari Linux - Software 4 11-12-2011 11:27 AM
I hate to be called a "CODER", "PROGRAMMER"...when.. StevenO General 5 08-01-2007 04:34 PM
Can't install "glibmm" library. "configure" script can't find "sigc++-2.0&q kornerr Linux - General 4 05-10-2005 03:32 PM
Writing shell script called "convert" bluewolf Programming 3 02-04-2003 11:52 PM


All times are GMT -5. The time now is 01:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration