LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 12-08-2003, 05:02 PM   #1
Askari
LQ Newbie
 
Registered: Nov 2003
Posts: 2

Rep: Reputation: 0
Scripting


ok I'm a newb at this so I'm not sure if I'm doing this right. Any suggestions would be appreciated. I need to make a script that takes in a userid as an argument. it then takes the userid to obtain the user's name from the /etc/passwd file with the cut command. it should then prompt if the user wants to enter another userid. if yes, then it'll repeat the script, if no, then it'll end. Thanks
#!/bin/bash
echo
===================================================================
echo Welcome to Linux Login
echo Created by RC
echo ===================================================================

answer=y
while [ "$answer" = "y" ]; do
if [ $# = -lt 1 ]
then
echo -n "Enter userid: "
read userid
fi
if [ "$1" ]; then
x=$1
else
user=$userid
new=$(grep $userid /etc/passwd | cut -f5 -d
echo $new
echo "Would you like to enter another userid? (y)es or (n)o"
if [ "answer" != "y" ]
then
read answer
fi
done
 
Old 12-09-2003, 09:25 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Here are some changes, you will need to make one or two more for your homework.
[code]
(Hint: use code tags )
Code:
answer="y"
while [ "$answer" = "y" ]; do
   if [ $# -lt 1 ] ; then
     echo -n "Enter userid: "
          read userid
     else
          userid="$1"
   fi
   echo "`$(grep '$userid' /etc/passwd | cut -f5 -d`"
   echo "Would you like to enter another userid? (y)es or (n)o "
   read answer   
done
-- note that you will keep checking for the same userid if you ask to continue.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
new to scripting mifan Linux - Newbie 2 08-17-2005 12:10 PM
another help with scripting?! ice99 Programming 2 08-09-2005 08:56 AM
Need help scripting Tamara Programming 7 06-06-2005 02:06 AM
Scripting Help Please Jazinator Linux - Newbie 7 10-17-2004 06:35 PM
scripting bforest Linux - Newbie 4 05-11-2004 02:45 AM


All times are GMT -5. The time now is 09:34 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration