Visit Our UNIX and Linux User Community


maximum number of arguments


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers maximum number of arguments
# 1  
Old 10-17-2007
maximum number of arguments

Hi,

What is the maximum number of arguments that could be passed to zsh ?

To find out that I tried a simple script.

And the maximum number of arguments that could be passed turned out to be 23394

Code:
#! /bin/zsh

arg=1

i=1
subIndex=23000
while [ $i -le $subIndex ]
do
  arg=$arg" "$i
  i=$(($i + 1))
done

while :
do
  line="./subTest.zsh "$arg
  echo "$line" | zsh
  i=$(($i + 1))
  arg=$arg" "$i
done

exit 0

Code:
>cat subTest.zsh
#! /bin/zsh

echo "Argument count: ${#}"

exit 1

Am not sure whether this approach is current or not.

Or is the maximum number of arguments that could be passed to a shell stored somewhere ?

Please, shed some light upon this
# 2  
Old 10-17-2007
Hi.

At a quick skim, the article at The maximum length of arguments for a new process looked like it covered most of the bases ... cheers, drl
# 3  
Old 10-18-2007
Thanks for that and I had a chance to look at that link already

To verify the numbers displayed are the maximum number of arguments that could be passed to zsh, I tried the small script posted above

But the numbers turned out to be quite different and wondering why there is a difference in the maximum number of arguments I could pass and to those that is listed.

Any thoughts about this ?
# 4  
Old 10-18-2007
There are two blocks of variable data passed to a new process...

1. environment variables

2. command line arguments

When "exec" is called the kernel has to hold them somewhere while it loads in the new program.

So it may not be the number of arguments, but the length of all the strings plus some management overhead.
# 5  
Old 10-18-2007
Quote:
Originally Posted by porter
There are two blocks of variable data passed to a new process...

1. environment variables

2. command line arguments

When "exec" is called the kernel has to hold them somewhere while it loads in the new program.

So it may not be the number of arguments, but the length of all the strings plus some management overhead.

Does that mean if the maximum number of arguments that can be passed is 'x' and the number of environmental variables to a binary is 'y', then the "actual" number of arguments that can be passed is only 'x' - 'y'

I believe, each of the command that is typed in the shell has to obey "fork" and "exec" to execute the command


Thanks for the reply
# 6  
Old 10-18-2007
Quote:
Originally Posted by matrixmadhan
Does that mean if the maximum number of arguments that can be passed is 'x' and the number of environmental variables to a binary is 'y', then the "actual" number of arguments that can be passed is only 'x' - 'y'
The actual limits/rules is down to the specific operating system.

Quote:
Originally Posted by matrixmadhan
I believe, each of the command that is typed in the shell has to obey "fork" and "exec" to execute the command
Yes, exec is the only way a new program gets loaded under UNIX.
# 7  
Old 10-18-2007
Quote:
The actual limits/rules is down to the specific operating system.
Ok.
The its a question about the link posted by drl -- why my script showed different numbers ( as maximum number of arguments possible ) to that of the numbers shown in the link
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #220
Difficulty: Easy
When multiple routers are used in interconnected networks, the routers can exchange information about destination addresses using a routing protocol.
True or False?

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Maximum number of sed squeezing

Hi all, What is the maximum number of sed squeezing in one shell?? I've surprised with this message when I squeezed 50 sed in the same shell: 253: Identifier too long - maximum length is 18.This is what I've did in my sed query | sed -e "s/ 0 /Default /" | sed -e "s/ 1 ... (2 Replies)
Discussion started by: leo_ultra_leo
2 Replies

2. Shell Programming and Scripting

Maximum number from input by user

I am trying to calculate the maximum number from four numbers input by the user. I have the following code, but it does not work. It says there's an error with the last line "done". Any help would be appreciated. max=0 echo "Please enter four numbers: " for i in 1 2 3 4 do read number... (17 Replies)
Discussion started by: itech4814
17 Replies

3. Shell Programming and Scripting

Maximum command line arguments

Hi, Can anyone please help me to know what is the maximum number of command line arguments that we can pass in unix shell script? Thanks in advance, Punitha.S (2 Replies)
Discussion started by: puni
2 Replies

4. Shell Programming and Scripting

Maximum number of characters in a line.

Hi, Could any one please let me know what is the maximum number of characters that will fit into a single line of a flat file on a unix. Thanks. (1 Reply)
Discussion started by: Shivdatta
1 Replies

5. UNIX for Dummies Questions & Answers

ls - maximum number of files

what is the maximum number ls can list down (6 Replies)
Discussion started by: karnan
6 Replies

6. Solaris

Maximum Number of threads suuported????

Hi, Anybody knows the maximum number of threads suuported by a process in solaris os. Please reply Thanks in advance :( (1 Reply)
Discussion started by: Agnello
1 Replies

7. Programming

maximum number of dots in a domain name

maximum number of dots in a domain name - not a sub-domain name. for example: mydomain.com ------ one dot mydomain.com.au ------ two dots do you know maximum number of dots in a domain name and could you provide a sample? thx. (1 Reply)
Discussion started by: hello20009876
1 Replies

8. UNIX for Dummies Questions & Answers

Maximum number of users allowed

How do i determen (what command) the max. number of users allowed Thanks in advance (10 Replies)
Discussion started by: siza
10 Replies

9. UNIX for Advanced & Expert Users

Maximum number of threads per user

Anybody knows how to setup Maximum number of threads per user or some other value on Sun Solaris 8. (1 Reply)
Discussion started by: s_aamir
1 Replies

Featured Tech Videos