Error in shell script when #!/bin/bash is used as shebang


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error in shell script when #!/bin/bash is used as shebang
# 1  
Old 11-18-2009
Error in shell script when #!/bin/bash is used as shebang

Code:
#!/bin/ksh

echo -en "\033[1;32mEnter ACTIVATION KEY:\033[0m"
read ACTIVATION_KEY
case "$ACTIVATION_KEY" in +([a-z]|[A-Z]|[0-9]|'-'))
echo -e "\033[1;32mPatern Matched\033[0m"
;;
*)
echo -e "\033[1;32mYou seem to have entered wrong characters in both the earlier instances. Pattern matching failed\033[0m"
;;
esac

The above script works fine when the interpreter is ksh, but outputs the following error when #!/bin/bash is used as shebang:

Code:
test.sh: line 5: syntax error near unexpected token `('
test.sh: line 5: `case "$ACTIVATION_KEY" in +([a-z]|[A-Z]|[0-9]|'-'))'

# 2  
Old 11-18-2009
In bash the extended glob is not enabled by default, add this line before the lines containing the extended syntax +():

Code:
shopt -s extglob

# 3  
Old 11-18-2009
Thanks got itSmilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ? --- Post updated at 08:39 AM --- in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
Discussion started by: i4ismail
3 Replies

2. Shell Programming and Scripting

C shell script wont terminated if i don't modify the shebang

Hi all, I'm new to shell script i wrote some shell script for my colleague, everyone is fine,except on user we are using VNC viewer to work and there are some script start with shebang #! /bin/csh there is an user will not terminate after running the script even if a hello world i need... (5 Replies)
Discussion started by: pilistar0222
5 Replies

3. Shell Programming and Scripting

Usage of #!/bin/sh vs #!/bin/bash shell scripts?

Some question about the usage of shell scripts: 1.) Are the commands of the base shell scripts a subset of bash commands? 2.) Assume I got a long, long script WITHOUT the first line. How can I find out if the script was originally designed für "sh" or "bash"? 3.) How can I check a given... (3 Replies)
Discussion started by: pstein
3 Replies

4. Shell Programming and Scripting

Question about Shebang line of Bash Script

Hello All, I was writing a Bash shell script that will be executed on both an AIX server (/usr/bin/ksh) and a SLES server (/bin/bash). The AIX server has Bash installed at "/usr/bin/bash", which is in a different dir then the SLES server. So basically I am writing the script on the SLES... (4 Replies)
Discussion started by: mrm5102
4 Replies

5. Shell Programming and Scripting

How to start powershell with shebang from windows/cygwin/bash?

I would like to the the windws8/cygwin/bash shebang feature to start a powershell script. I do a "chmod +x set-sound.ps1" and then at a bash prompt I do ./set-sound.ps1 The first line of ./set-sound.ps1 #!powershell.exe -ExecutionPolicy unrestricted The result is the result: ... (5 Replies)
Discussion started by: siegfried
5 Replies

6. Shell Programming and Scripting

Can we use two shebang statements in a single shell script?

Hi, As per my understanding, we can use two shebang statements in a single shell script. Please see below snippet- #!/bin/bash .......## some code A #!/bin/csh .......## some code B exit 0; Here, code A will be executed using bash shell and code B will be executed with c shell. ... (9 Replies)
Discussion started by: tarunmudgal4u
9 Replies

7. Shell Programming and Scripting

how to Install jdk.bin using shell script with auto yes/no?

#!/bin/sh echo "Installing Java!!!" cd /opt echo "Want to give execute Permissions to java!!!" chmod 755 jdk-6u7-linux-i586.bin echo "Executing the jdk script" ./jdk-6u7-linux-i586.bin This is the shell commands I am using... I want to know how to give answer to yes and no automatically... (6 Replies)
Discussion started by: sandeepbharmori
6 Replies

8. Programming

Python converted from /bin/sh shell - backup script.

Hello, I have a shell script I wrote in /bin/sh to backup my web sever. I am now on a host (someone reselling rackspace server hosting to me) and when setting up cron, it actually has a dropdown list of "command languages" that you have to choose from. my options are: ruby php perl... (0 Replies)
Discussion started by: jzacsh
0 Replies

9. Shell Programming and Scripting

#!/bin/bash and #1bin/sh command not found error on mac osx terminal/shell script

i am having a weird error on mac os x running some shell scripts. i am a complete newbie at this and this question concerns 2 scripts. one of which a friend of mine wrote (videochecker.sh) a couple weeks ago and it's been running fine on another machine. then last week i wrote capture.sh and it... (2 Replies)
Discussion started by: danpaluska
2 Replies

10. UNIX for Dummies Questions & Answers

fuser: difference with bin/sh and bin/ksh shell script

Hi, I have a problem I don't understand with fuser. I launch a simple shell script mysleep.sh: I launch the command fuser -fu mysleep.sh but fuser doesn't return anything excepted: mysleep: Then I modify my script switching from #!/bin/sh to #!/bin/ksh I launch the command fuser -fu... (4 Replies)
Discussion started by: Peuj
4 Replies
Login or Register to Ask a Question