Subscipt out of range - Error (ksh)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Subscipt out of range - Error (ksh)
# 1  
Old 01-12-2007
Subscipt out of range - Error (ksh)

Folks,

I have peculiar kind of error. my script goes like

cat inputfile> while read param
do
Array[$i]=$param
y=`expr $y + 1`
done

When i run script passing very large input file. script abends in the middle of execution saying "ksh: script out of range"
Possible reason is max array element size is 4095 which is exceeded in my case. Now my question, is there any settings in shell which i can use to increase the max array element size.


Guys please post ur suggestions.


Thanks!
Sharif.S
# 2  
Old 01-12-2007
Quote:
Originally Posted by sharifhere

cat inputfile> while read param
do
Array[$i]=$param
y=`expr $y + 1`
done
It could be something related to shell's limits, though, the script seems to be incomplete, isn't it?
Perhaps it should be something like:
Code:
i=1
while read param; do
   Array[$i]=$param
   i=$(expr $i + 1)
done < inputfile

# 3  
Old 01-12-2007
THanks for ur reply.


Part of the script was only posted there..

the real problem is when array element exceeds 4095 range.. script fails..
eg:
cat inputfile| while read param
do
array[$i]=$param
echo "array[$i]" array[$i]
done

Output:-

array[1]=line1
array[2]=line2
array[3]=line3
.
.
.
.
array[4095]=line
ksh: script out of range

so after element count crosses 4095 range script fails.


any ways to increase this max size limit

Thanks!
Sharif.S
# 4  
Old 01-12-2007
Quote:
Originally Posted by sharifhere
THanks for ur reply.


Part of the script was only posted there..

the real problem is when array element exceeds 4095 range.. script fails..
eg:
cat inputfile| while read param
do
array[$i]=$param
echo "array[$i]" array[$i]
done

Output:-

array[1]=line1
array[2]=line2
array[3]=line3
.
.
.
.
array[4095]=line
ksh: script out of range

so after element count crosses 4095 range script fails.


any ways to increase this max size limit

Thanks!
Sharif.S
I had to ask Smilie
Exactly, there is a limit in ksh. What I do not know yet is if it is possible to increase that number.
Otherwise, you could use bash, whose limit (at least on my OS/version) is much higher.
# 5  
Old 01-12-2007
try using bash

hey dude..


y dont u try using bash shell!

Cheers,
bourne!
# 6  
Old 01-12-2007
He may not have it on his box..... there are other unix systems that do not have bash out of the box, and it requires root access to install GNU goodies. IF one exists for his box.
# 7  
Old 01-12-2007
Sorry guys, i had to use only ksh .. any other possible ways..

Thanks,
Sharif.S
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

File System Error: BAD SUPERBLOCK AT BLOCK 16: NUMBER OF DIRECTORIES OUT OF RANGE

Hi All, we are having a file system error in one of our servers. The server failed to boot in usual user mode. Instead boot with single user mode and requesting to run a FSCK manually to repair the corrupted. see the below output. Netra T2000, No Keyboard Copyright 2008 Sun Microsystems,... (5 Replies)
Discussion started by: Buddhike G
5 Replies

2. Red Hat

Subject: value out of range error on a disk with free 40 GB space

Hi, I installed RHEL 6.0 OS on vmware with CREATE CUSTOM LAYOUT option. And I gave the space to different mount points as mentioned below: / 15360MB /boot 200MB /tmp 3072 MB swap 1024 MB fdisk -cul command shows the disk size as 64.4 GB. But when I try to create partion of 10 GB with... (1 Reply)
Discussion started by: GAURAV SRIVASTA
1 Replies

3. UNIX for Advanced & Expert Users

Help with ksh script to list, then cp files from a user input date range

Hi, I'm quite new to ksh scripting, can someone help me with this. Requirements: I need to create a script that list the files from a user input date range. e. g. format of file: *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00* *c1*log.2012-12-22-14-00*... (1 Reply)
Discussion started by: chococrunch6
1 Replies

4. Shell Programming and Scripting

for i in range ksh

Hi guys i have one handy script which is written in bash and it was using `seq ` , since we want to modified it to ksh script. i have tried couple of tricks to work around for i in $(x..y) like syntax it dont work . below is the actual code can somebody help me on it #!/bin/ksh if... (4 Replies)
Discussion started by: tapia
4 Replies

5. Shell Programming and Scripting

Receiving error: ./ang.ksh[35]: 0403-057 Syntax error at line 116 : `done' is not expected.

Hi All I am quite new to Unix. Following is a shell script that i have written and getting the subject mentioned error. #!/bin/ksh #------------------------------------------------------------------------- # File: ang_stdnld.ksh # # Desc: UNIX shell script to extract Store information.... (3 Replies)
Discussion started by: amitsinha
3 Replies

6. Ubuntu

ksh error

hi, When I try to go to het ksh shell i get het errror below. Deleting, reinstalling via apt-get does'nt work. Manually deleting and then reinstalling also does'nt work. Any seen this error before? ksh ksh: error while loading shared libraries: libdll.so: cannot open shared object file:... (1 Reply)
Discussion started by: jld
1 Replies

7. Shell Programming and Scripting

grep error: range endpoint too large

Hi, my problem: gzgrep "^.\{376\}8301685001120" filename /dev/null ###ERROR ### grep: RE error 11: Range endpoint too large. Whats my mistake? Is the position 376 to large for grep??? Thanks. (2 Replies)
Discussion started by: Timmää
2 Replies

8. Shell Programming and Scripting

time stamp perl script error out of range 1..31

Hi, while running the perl script i am getting this error message , Day '' out of range 1..31 at rsty.sh line 44 what do iam missing in the script, any suggestion #!/usr/bin/perl use Time::Local; my $wday = $ARGV; my $month = $ARGV; # convert the month shortname into 0-11 number if... (4 Replies)
Discussion started by: saha
4 Replies

9. Shell Programming and Scripting

print range between two patterns if it contains a pattern within the range

I want to print between the range two patterns if a particular pattern is present in between the two patterns. I am new to Unix. Any help would be greatly appreciated. e.g. Pattern1 Bombay Calcutta Delhi Pattern2 Pattern1 Patna Madras Gwalior Delhi Pattern2 Pattern1... (2 Replies)
Discussion started by: joyan321
2 Replies

10. UNIX for Dummies Questions & Answers

Ksh error

I am running the below script to call an already existing concurrent program using the CONCSUB utility. #!/bin/ksh echo "==================================================" echo "Beginning program " `date "+%m/%d/%y %H:%M:%S"` "\n" echo "=================================================" #... (1 Reply)
Discussion started by: Begins
1 Replies
Login or Register to Ask a Question