LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices



Reply
 
Search this Thread
Old 08-27-2012, 11:37 AM   #1
slufoot80
Member
 
Registered: Nov 2011
Posts: 63

Rep: Reputation: Disabled
Exclamation Function error


below is my script when it calls the function it says:
================================================
/usr/sbin/adduser: line 14: userinfo: command not found
/usr/sbin/adduser: line 15: shellsel: command not found
===================================================== userinfo is a function I'm calling and so is shellsel


#Script to add a user to this Linux system
#!/bin/bash
clear

if [ $(id -u) -eq 0 ]; then

echo -ne "\nIndividual Account or Environment Account\n"
echo -e "1) Individual Account\n"
echo -e "2) Environment Account\n"
echo -ne "Enter choice: ";read acctchoice;

case $acctchoice in
1)
userinfo
shellsel
;;

2)
userinfo
shellsel
ln -s $homedir /forms/$username"sa"

;;
esac

fi


function shellsel()
{
echo ""
echo "Select the type of shell you will be using"
echo""
echo -e "1) Bash Shell - SFTP Secure\n" # Shell selection statement
echo -e "2) False Shell - FTP Unsecure\n"
echo -ne "Enter choice: ";read shell;
case $shell in
1)
shell=/bin/bash # case statment for shell selection.
commentstatic="Internal SFTP Account"
useradd -u $uid -p $pass -c "$comment $commentstatic" -d $homedir -s $shell $username
echo -e "Copying System Files ...."
cd /nas_ftp5/Customer/Imaging/Troy/T_Skel
cp -Rp `ls` $homedir
echo -e "Finished Copying System Files ..."
tail -1 /etc/passwd > $homedir/etc/passwd
echo "$username" >> /etc/ftpusers
;;
2)
shell=/bin/false
commentstatic="Internal FTP Account"
useradd -u $uid -p $pass -c "$comment $commentstatic" -d $homedir -s $shell $username
;;
esac
return $TRUE
}


function userinfo()
{
read -p "Enter User Name : " username

while [ -z $username ]|| egrep "^$username" /etc/passwd 1>/dev/null;
do
echo -ne "Either user exists or you entered a blank, enter username again: ";read -e username
done

echo -ne "Enter your password: ";read -s password

while [ -z $password ];
do
echo -ne "\nEnter your password again: ";read -s -e password
done

echo -ne "\nPlease Enter your User ID Number: ";read -ern5 uid
while [[ ! $uid =~ ^[0-9]+$ ]]||egrep $uid /etc/passwd >/dev/null; do
echo -ne "Please re-enter your uid positive intergers only: ";read -ern5 uid
done

read -p "Enter a Comment : " comment
read -p "Enter Users Home Directory : " homedir
while [ ! -d "$homedir" ];
do
echo -ne "\n$homedir Directory Not Found! Please re-enter: "; read homedir
done
pass=$(perl -e 'print crypt($ARGV[0], "password")' $password) # passing the password entered
return $TRUE
}
 
Old 08-27-2012, 02:35 PM   #2
kakaka
Member
 
Registered: Sep 2003
Posts: 382

Rep: Reputation: 86
I put the code for your script in a file, moved the function definitions before the main if, and they were then found by bash.
 
  


Reply

Tags
function, shell scripting


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
GnuTLS error -53: Error in the push function | vsftpd and explicit FTP over TLS Kaiser Soze Linux - Server 0 09-05-2011 06:53 PM
[SOLVED] g++ error message no matching function for call to some function Jerry Mcguire Programming 6 04-13-2010 09:37 PM
error :In function 'main': studentlb Programming 12 11-08-2006 05:57 PM
error function in c code shams Programming 3 08-06-2004 05:00 AM
error coding a function in c shams Mandriva 1 07-28-2004 01:09 AM


All times are GMT -5. The time now is 11:42 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration