Sponsored Content
Full Discussion: arguments in command line
Top Forums UNIX for Dummies Questions & Answers arguments in command line Post 302081671 by rrs on Thursday 27th of July 2006 03:07:54 AM
Old 07-27-2006
arguments in command line

Hi all,

How many arguments can we pass while testing a prgm at command line..
I encountered an issue while passing 10 arguments.
For $10 its taking argument passed for $1 followed by 'zero'.

can we pass more than 9 arguments /Is there any other way.

Thanks,
rrs
 

10 More Discussions You Might Find Interesting

1. Programming

command line arguments

Hi How to pass multi line text as a command line argument to a program. (i.e) ./a.out hi this is sample 0 file1 where hi this is sample should be stored in argv 0 in argv and so on... (3 Replies)
Discussion started by: bankpro
3 Replies

2. Shell Programming and Scripting

command line arguments

-------------------------------------------------------------------------------- I have this while loop and at the end I am trying to get it to tell me the last argument I entered. And with it like this all I get is the sentence with no value for $1. Now I tried moving done after the sentence... (1 Reply)
Discussion started by: skooly5
1 Replies

3. Shell Programming and Scripting

Getting error in command line arguments

Hi, When i am running the following script 1.sh (without giving the command line arguments) then i am getting the following error. if then echo "UID and PWD are correct" elif then echo "Either UID or PWD is wrong. Please check your UID and PWD" else echo "UID and PWD can't be blank"... (9 Replies)
Discussion started by: sunitachoudhury
9 Replies

4. UNIX for Dummies Questions & Answers

Command line arguments.

I am working on a script wherein i need the user to enter the Build ID for eg:the command line will show enter the build ID Now on entering the build ID it should be assigned to @ARGV. How can this be done.? (1 Reply)
Discussion started by: Varghese
1 Replies

5. UNIX for Dummies Questions & Answers

getopts - command line arguments

Hi, I'm having problems with a script where I wanted every single option specified in the command line to have an argument taken with it, but for some reason only d works in the code I will be showing below. For example if I did ./thisfile -a something it would come up with "a chosen with " as... (2 Replies)
Discussion started by: IceX
2 Replies

6. 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

7. UNIX for Dummies Questions & Answers

command line arguments

hi, can someone how to accept command line arguments as a variable using in script? like: ./scriptname arguments by accept arguments, I can use it in my script? thx! (1 Reply)
Discussion started by: ikeQ
1 Replies

8. Shell Programming and Scripting

Command Line Arguments - not working

I am new to the world of Unix and shell scripting and have been trying to get the following simple script to work: #!/bin/bash echo "what is your age?" echo "you are $1 years old"I want to be able to enter my age on the command line, when prompted, and it return the... (1 Reply)
Discussion started by: meursault
1 Replies

9. Shell Programming and Scripting

command line arguments

hi,,,, I want to create a command prompt, for example "prompt>", so my prompt need to handle commands, for example "prompt>cmd", so i want to know how to get arguments for my own commands cmd, i.e. default argc should contain arguments count and argv should point to the argument vector i.e, for... (2 Replies)
Discussion started by: vins_89
2 Replies

10. Shell Programming and Scripting

Command line arguments for addition

Hi all, I am trying to write a code for addition of n numbers which will be passed by the user as command line arguments. I wrote the following code. add=0 for (( i = 1 ; i <= $# ; i++ )) do add=`expr $i + $add` done #echo "sum is : $add" input : $./add.sh 12 32 14... (7 Replies)
Discussion started by: PranavEcstasy
7 Replies
varargs(5)							File Formats Manual							varargs(5)

NAME
varargs - handle variable argument list SYNOPSIS
DESCRIPTION
This set of macros enables programmers to write portable procedures that accept variable argument lists. Routines that have variable argu- ment lists (such as but do not use are inherently nonportable, because different machines use different argument-passing conventions (see printf(3S)). is used as the parameter list in a function header. is a declaration for No semicolon should follow is a type defined for the variable used to traverse the list. is called to initialize pvar to the beginning of the list. The type of argN should be the same as the argument to the function just before the variable portion of the argument list. returns the next argument in the list pointed to by type is the type the argument is expected to be. Different types can be mixed, but it is up to the routine to know what type of argument is expected, because it cannot be determined at runtime. is used to clean up. Multiple traversals, each bracketed by are possible. NOTE: The header file is provided for compatibility with pre-ANSI compilers and earlier releases of HP C/HP-UX. It is superceded by which includes all of the macros. EXAMPLE
The following example shows a possible implementation of (see exec(2)): The next example illustrates how a function that receives variable arguments can pass these arguments down to other functions. To accom- plish this, the first routine in this example) which receives the variable argument list must pass the address pointer resulting from a call to on to any subsequent calls that need to access this same variable argument list. All routines that receive this address pointer in this example) need only to use to access the original variable argument list just as if they were the original routine to be passed the variable arguments. In this example, one can imagine that there are a series of other routines (such as a and that also call the function. #include <stdio.h> #include <varargs.h> #include <unistd.h> int error_count; /* VARARGS4 -- for lint */ int log_errors(log_fp, func_name, err_num, msg_fmt, va_alist) FILE *log_fp; char *func_name; int err_num; char *msg_fmt; va_dcl { va_list ap; /* Print error header information */ (void) fprintf(log_fp, " ERROR in process %d ", getpid()); (void) fprintf(log_fp, " function "%s": ", func_name); switch(err_num) { case ILLEGAL_OPTION: (void) fprintf(log_fp, "illegal option "); break; case CANNOT_PARSE: (void) fprintf(log_fp, "cannot parse input file "); break; ... } /* * Get pointer to first variable argument so that we can * pass it on to v_print_log(). We do this so that * v_print_log() can access the variable arguments passed * to this routine. */ va_start(ap); v_print_log(log_fp, msg_fmt, ap); va_end(ap); } /* VARARGS2 -- for lint */ int v_print_log(log_fp, fmt, ap) FILE *log_fp; char *fmt; va_list ap; { /* * If "%Y" is the first two characters in the format string, * a second file pointer has been passed in to print general * message information to. The rest of the format string is * a standard printf(3S) format string. */ if ((*fmt == '%') && (*(fmt + 1) == 'Y')) { FILE *other_fp; fmt += 2; other_fp = (FILE *) va_arg(ap, char *); if (other_fp != (FILE *) NULL) { /* * Print general message information to additional stream. */ (void) vfprintf(other_fp, fmt, ap); (void) fflush(other_fp); } } /* * Now print it to the log file. */ (void) vfprintf(log_fp, fmt, ap); } WARNINGS
It is up to the calling routine to specify how many arguments there are, because it is not always possible to determine this from the stack frame. For example, is passed a zero pointer to signal the end of the list. can determine how many arguments are present by the format. It is non-portable to specify a second argument of or to because arguments seen by the called function are not or C converts and arguments to and converts arguments to before passing them to a function. SEE ALSO
exec(2), vprintf(3S), stdarg(5). STANDARDS CONFORMANCE
varargs(5)
All times are GMT -4. The time now is 09:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy