when I used your correction to my script, it already went to the Invalid code.. blah blah.. then it terminated..But the username I entered is really in the login_users script..
what is the problem in this??
@chubler XL
That's what I'm thinking about.. but how can I do the sudo script??
These are the scripts related to the password recovery..
Here is the script to add accounts in the login_users
Code:
#============================================================
# Script Name: useradd
# By: JRG
# Date: March 5, 2011
# Purpose: A shell script used to add
# new user accounts to the login_users file
# Command Line: useradd
#===========================================================
trap "rm ~/tmp/* 2> /dev/null; exit" 0 1 2 3
userfile=~/casestudies/login_users
clear
tput cup 1 4; echo "User Accounts Addition"
tput cup 2 4; echo "======================="
tput cup 4 4; echo "Username : "
tput cup 5 4; echo "Password : "
tput cup 6 4; echo "Answer the following questions in case of password recovery"
tput cup 7 2; echo "A. What is your 5th favorite color? "
tput cup 8 2; echo "B. What is your favorite food? "
tput cup 9 2; echo "C. What is the name of your pet? "
tput cup 10 2; echo "D. What is the middle name of your mother's maiden name? "
tput cup 11 2; echo "E. What is the model number of your laptop/monitor? "
tput cup 4 18; read username
tput cup 5 18; read passwd
tput cup 7 18; read A
tput cup 8 18; read B
tput cup 9 18; read C
tput cup 10 18; read D
tput cup 11 18; read E
# Check to see if username is not blank before you
#write to disk
if [ "$username" > " " ]
then echo "$username:$passwd:$A:$B:$C:$D:$E" >> $userfile
fi
tput cup 13 10; echo "(q)uit: "
tput cup 13 10; read choice
if [ "$choice" = "q" ]
then
clear; exit
fi
Printing of lists
Code:
#============================================================
# Script Name: userlist
# By: JRG
# Date: March 5, 2011
# Purpose: Use awk to format colon-separated fields
# in a flat file and display to the screen
# Command Line: userlist
#===========================================================
clear
tput cup 2 4; echo "User List"
tput cup 3 4; echo "========="
tput cup 5 0; echo "P - Print User List"
awk -F: '{printf "%-12s %-12s %s\t%s %s %10.10s %s\n", $2, $3, $4, $1, $5, $6, $7}' login_users
To select which one to do..
Code:
#============================================================
# Script Name: profile
# By: JRG
# Date: March 5, 2011
# Purpose: main menu
# Command Line: profile
#===========================================================
profile=~/casestudies/users
loop=y
while [ "$loop" = y ]
do
clear
tput cup 3 12; echo " Welcome to your profile "
tput cup 4 12; echo "==========================="
tput cup 6 9; echo "What do you want to do? "
tput cup 7 9; echo "C - create an account"
tput cup 8 9; echo "L - Login"
tput cup 9 9; echo "F - Forgot password"
tput cup 10 9; echo "Q - Quit"
read choice || continue
case $choice in
[Cc]) ./useradd;;
[Ll]) ./login1 ;;
[Ff]) ./forgotpass;;
[Qq]) exit ;;
*) tput cup 13 4; echo "Invalid Code"; read choice ;;
esac
done
Hi,
I want to check if a variable has a value assigned to it or not.
I can do following -
cat $Var > File1
if
then
echo "$Var has value"
else
echo "$Var is null"
fi
But I have to check for 3 Variables and I want to wrap it up in couple of unix statements.
Any... (3 Replies)
Can any one help us in finding the the last word of each line from a text file and print it.
eg:
1st --> aaa bbbb cccc dddd eeee ffff ee
2nd --> aab ered er fdf ere ww ww f
the o/p should be a below.
ee
f (1 Reply)
Hi,
i'm posting this in the Solaris forum although maybe it should be better in the General unix forum, I'm formatting an output witht he following command:
crontab -l | grep GBOUAT8 | grep UTP | grep -i stop | sed 's/\\//'
08 2 * * 2-6 /apps/sum_glob/gbo_uat/sparse/bin/dmg_cronlaunch -ENVI... (2 Replies)
Hi Everyone,
I am looking for a simple way for replacing all the files under a directory that use the server "xsgd1234dap" with "xsdr3423pap".
For Example:
In the Directory,
$pwd
/home/nick
$ grep -l "xsgd1234dap" *.sh | wc -l
119
I have "119" files that are still using... (5 Replies)
I am trying to check whether a variable has been assigned on the command line or not.
Here is what I did:
#!/usr/bin/bash
if( $variable == '\0')
{
print "variable was not assigned"
exit
}
else
NF = 2 {print $1, ""}
exit
fi
awk -f question1.awk variable = 58 letters.txt.
So... (3 Replies)
I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL.
I need the whole word... (6 Replies)
example:
i have the following text file...
i am very tired.
i am busy
i am hungry
i have to find the number of occurence of a particular word 'am' from the text file.. can any one give the shell script for it (34 Replies)
I need to find a word '% Retail by State' in the folder /usr/sas/reports/RetailSalesTaxallocation.
When I tried like below,
-bash-4.1$ cd /usr/sas/reports/RetailSalesTaxallocation
-bash-4.1$ find ./ -name % Retail by State
find: paths must precede expression: Retail
Usage: find ... (10 Replies)
Hi All,
I am looking for a perl/awk/sed command to auto-increment the numbers line in file, P1.tcl:
run_build_model sparc_ifu_dec
run_drc
set_faults -model path_delay -atpg_effectiveness -fault_coverage
add_delay_paths P1
set_atpg -abort_limit 1000
run_atpg -ndetects 1000
I would like... (6 Replies)