![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Unix Korn Shell Array Issue (SunOS) | Janus | Shell Programming and Scripting | 5 | 11-21-2006 08:19 PM |
| Help with Korn Shell script | heprox | AIX | 1 | 12-19-2005 02:04 PM |
| korn shell script | pavan_test | UNIX Desktop for Dummies Questions & Answers | 3 | 10-27-2005 12:09 PM |
| korn shell array? | cstovall | Shell Programming and Scripting | 5 | 01-28-2005 05:40 PM |
| Oracle To Korn Shell Array | kdst | UNIX for Advanced & Expert Users | 1 | 09-24-2002 09:21 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I can't declare an array in my korn shell script
I have a script that contains
#!/usr/bin/ksh set -A X 'hallo' 'world' echo ${X[0]} echo ${X[1]} when I execute it I get an errror message sh ./test.ksh ./test.ksh: -A: bad option(s) but if I do this at the command prompt I am able to create it set -A myarray '1' '2' '3' echo ${myarray[0]} 1 echo ${myarray[1]} 2 echo ${myarray[2]} 3 my shell is echo `basename $0` -ksh why can't I create an array in my script thanks Last edited by zilla30066; 01-25-2007 at 09:17 AM.. |
|
||||
|
Your script is just fine, you just start it wrong.
Instead of sh ./test.sh it shoould be only ./test.sh The first line in the script indicates it should run in a Korn Shell "#!/usr/bin/ksh" When you start with the command sh ./test.sh you overrule this since you explicitly tell the script to run in a Bournse (sh) shell. So just ./test.sh is the correct way to start it. As indicated the x right needs to be switched on. chmod +x test.sh |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|