[RESOLVED] Script not working« Back to Questions List

Hi Team, I am facing issue with shell script for user add in shell. please find below code and suggest what went wrong with it. #!/bin/bash function usradd { check_user=`grep $1 /etc/passwd` if [ -z "$check_user" ]; then echo "user $1 not found" useradd $1 echo "user added successfully" else echo "user $1 found" exit 1 fi } read -p "Enter username:" user function usrmod { check_usershell=`grep $2 /etc/shells` if [ -z "$check_usershell" ]; then echo "shell $2 found" usermod -s $3 `grep $1 /etc/passwd` echo "user modified" else echo "user not found" exit 1 fi } read -p "Please enter user shell:" shell usradd $user usrmod $shell
Posted by Mohammad Nazim Ansari
Asked on May 30, 2018 6:18 am
0

Script working fine

Posted by Mohammad Nazim Ansari
Answered On June 6, 2018 9:31 am