![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| passing variable from bash to perl from bash script | arsidh | Shell Programming and Scripting | 10 | 06-04-2008 09:25 AM |
| How do i change to super user then revert back to ordinary user ,using shell script? | wrapster | Shell Programming and Scripting | 3 | 06-04-2008 04:11 AM |
| Why generate "ash and bash" different output for same bash script? | s. murat | Shell Programming and Scripting | 0 | 05-26-2008 04:19 AM |
| Problem setting up Bash user account | sumanroyc | UNIX for Advanced & Expert Users | 2 | 10-27-2006 02:57 PM |
| Help with Flat Files Please!! BASH (New User) | cyberjax21 | Shell Programming and Scripting | 0 | 02-27-2006 06:19 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Bash - Add User script
Hey folks! I'm trying to work on a script that will add a user to the system. I have the complete script, but it's not working for me, and I'm not sure what to do.
line 53: syntax error near unexpected token `0' ******************************************************** Code:
#!/bin/bash
#
# complete add user script
#
initialize_variables ()
{
noinput=
user_id=' '
user_id_num=' '
home_directory=' '
group_id_num=' '
group_name=' '
#
#
cat /u/reedk/ulist|cut -f3 -d':'|sort -bg > luid_file
#
tuid=$(tail -1 luid_file)
let user_id_num=$tuid+1
echo "$user_id_num"
}
#
display_heading ()
{
clear
echo " ADD USER SCREEN "
echo " _________________________________"
}
main_menu ()
{
let doption=100
while [ $doption != 99 ]
do
display_heading
echo " 1. Enter user real name .................. $user_name "
echo " Next available user ID Number ......... $user_id_num "
echo " 2. Enter Group ID Number ................. $group_id_num "
echo " Group name .....$group_name"
echo " 3. Enter Home Directory ................. $home_directory "
echo " 4. Enter Default Shell .................. $default_shell "
echo " "
echo " user_add -c "$user_name" -d $home_directory -g $group_id_num -G $group_name -m -s $default_shell $strt_script "
echo " "
echo " 0. ADD USER NOW "
echo " "
echo " "
echo " 99. EXIT (Take no action) "
echo " ============================================================"
echo " Please select an option ===> "
read option
case $option in
0) echo " user_add -c "$user_name" -d $home_directory -g $group_id_num -G $group_name -m -s $default_shell $strt_script "
echo " $user_name has been added successfully"
sleep 5
;;
1) display_heading
echo "Please the users real name: (fi.mi.last) ==> "
read confirm_reply
if [ "$confirm_reply" = "$noinput" ]
then
echo " No user name entered"
else
user_name=$confirm_reply
home_directory=/u/$user_name
default_shell=/bin/bash
if [ "$user_name" = "$( cat /u/reedk/ulist|cut -f1 -d':'|grep $user_name) " ]
then
echo " User name already exists"
fi
fi
;;
2) display_heading
echo "Enter the primary Group ID Number ==> "
read confirm_reply
group_name=' '
if [ "$confirm_reply" = "$noinput" ]
then
echo "No primary group ID was entered"
else
grpfnd='n'
group_id_num=$confirm_reply
for i in $(cat /u/reedk/gfile|cut -f1,3 -d':')
do
if [ $(echo $i|cut -f2 -d':') -eq $group_id_num ]
then
grpfnd='y'
group_name=$(echo $i|cut -f1 -d':')
fi
done
if [ $grpfnd = 'n' ] || [ $group_id_num -eq 0 ]
then
echo "Invalid primary group number entered"
fi
fi
;;
99) let doption=99
;;
esac
done
}
#
###################################
# BEGIN MAIN PROGRAM #
###################################
if [ "$(whoami)" != "$( cat /u/reedk/auth.list|grep $(whoami) )" ]
then
echo " You are not authorized to run this script ... Contact your System Administrator "
else
initialize_variables
main_menu
fi
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
text in red is line 53
|
|
#3
|
||||
|
||||
|
Hi.
How many quotes do you count? ... cheers, drl |
|
#4
|
|||
|
|||
|
I'm not sure what you mean. On line 53 I have 4 double quotes (")
-2 open / 2 close The error message states: line 53: syntax error near unexpected token `0' But if you look at my actual code, there is no single quote next to the 0) /Confusion EDIT: I should add.. I'm pretty new to scripting and UNIX in general. I have some know how of programming in C+, but a few drinks in me know.. so I may just be not seeing what you tried to tell me. Last edited by niels.intl; 05-10-2008 at 05:30 PM. |
|
#5
|
||||
|
||||
|
Hi.
Yes, you are correct. I did not see all the way to the end of line 53. I apologize. One debugging tool is: Code:
set -x I extracted a segment of your script at the beginning of the case and it ran without error, so the problem is likely before that. If you cannot see the error, post a small portion of the "-x" output just before and including the error message ... cheers, drl |
||||
| Google The UNIX and Linux Forums |