LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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
 
Search this Thread
Old 08-25-2012, 06:36 AM   #1
Vashezz
LQ Newbie
 
Registered: Aug 2012
Posts: 1

Rep: Reputation: Disabled
Exclamation Syntax error near unexpected token ';;'


Code:
#!/usr/local/bin/bash
RSA_keys ()
{
echo "making folder rsakeys in /usr/home/"
if [ ! -d $HOME/rsakeys ]; then
cd $HOME
mkdir rsakeys
else
# rest code
fi
}
# Check openSSL
if [ ! -x "/usr/local/bin/openssl" ]; then
#
	echo -e "\033[1;31m OpenSSL not found!\033[0m"
	echo -e "\033[1;36m do you want install OpenSSL?\n\033[0m
	1 - yes\n
	2 - no"
		read odp
		case $odp in
		1*)
			cd /usr/ports/security/openssl
			make install clean
			RSA_keys()
		;; #here ive got error with ";;"
		2*)
			echo -e "...!"
		;;
		esac
	
else
echo "Script starting"
RSA_keys()
fi
When i tiring execute this script, ive recive message "rsagen.sh: line 25: syntax error near unexpected token ';;'"
rsagen.sh: line 25: ' ;;'
Maybe something in function is wrong and by this ive got eror in case?

Last edited by Vashezz; 08-25-2012 at 06:43 AM.
 
Old 08-25-2012, 07:45 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,451
Blog Entries: 54

Rep: Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893Reputation: 2893
Easiest way is to "set -vx" beforehand and watch where it goes belly up but once defined you don't use parenthesis anymore and in case statements you only use wildcards if really necessary. BTW could this be a more logical flow:
Code:
RSA_keys() { 
 echo "making folder rsakeys in ${HOME}/rsakeys"
 [ -d "$HOME/rsakeys" ] || { mkdir "$HOME/rsakeys" || exit 1; }
} # End RSA_keys

installSSL() { 
 echo -en "OpenSSL not found. Install? [Y|n] "; read ANSWER
 case "$ANSWER" in
  Y|y) cd /usr/ports/security/openssl && make install clean && RSA_keys;;
  N|n) echo "OK, exiting"; exit 127;;
  *) echo "Ze monkey pressing ze vrong buttonz."; exit 1;; 
esac
} # End installSSL

# Start by checking OpenSSL installation
HAS_OPENSSL=1
for ITEM in ${PATH//:/ }; do
 [ -x "${ITEM}/openssl" ] && HAS_OPENSSL=0
done; [ $HAS_OPENSSL -ne 0 ] && installSSL

echo "Script starting"
RSA_keys
 
1 members found this post helpful.
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax error near unexpected token `else' dnaqvi Linux - General 5 12-08-2010 03:37 AM
syntax error near unexpected token `else' alex0 Programming 7 07-28-2009 08:01 AM
syntax error near unexpected token -what does this mean? rmnature Linux - Newbie 5 02-14-2009 08:19 AM
syntax error near unexpected token Aigarzs Linux - Newbie 3 01-12-2008 03:39 PM
syntax error for unexpected token `(' Steve Spurr Linux - Newbie 6 09-22-2006 08:19 AM


All times are GMT -5. The time now is 02:47 AM.

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