02-02-2006
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[1]
0 in argv[2] and so on...
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
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 (6 Replies)
Discussion started by: rrs
6 Replies
2. Shell Programming and Scripting
--------------------------------------------------------------------------------
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
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
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
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
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
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
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
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
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
LEARN ABOUT ULTRIX
xrmoptiondescrec
XrmInitialize(3X11) MIT X11R4 XrmInitialize(3X11)
Name
XrmInitialize, XrmParseCommand, XrmValue, XrmOptionKind, XrmOptionDescRec - initialize the Resource Manager, Resource Manager structures,
and parse the command line
Syntax
void XrmInitialize();
void XrmParseCommand(database, table, table_count, name, argc_in_out, argv_in_out,)
XrmDatabase *database;
XrmOptionDescList table;
int table_count;
char *name;
int *argc_in_out;
char **argv_in_out;
Arguments
argc_in_out
Specifies the number of arguments and returns the number of remaining arguments.
argv_in_out
Specifies a pointer to the command line arguments and returns the remaining arguments.
database Specifies the resource database.
name Specifies the application name.
table Specifies the table of command line arguments to be parsed.
table_count
Specifies the number of entries in the table.
Description
The function initialize the resource manager.
The function parses an (argc, argv) pair according to the specified option table, loads recognized options into the specified database with
type ``String,'' and modifies the (argc, argv) pair to remove all recognized options.
The specified table is used to parse the command line. Recognized entries in the table are removed from argv, and entries are made in the
specified resource database. The table entries contain information on the option string, the option name, the style of option, and a value
to provide if the option kind is The argc argument specifies the number of arguments in argv and is set to the remaining number of argu-
ments that were not parsed. The name argument should be the name of your application for use in building the database entry. The name
argument is prefixed to the resourceName in the option table before storing the specification. No separating (binding) character is
inserted. The table must contain either a period (.) or an asterisk (*) as the first character in each resourceName entry. To specify a
more completely qualified resource name, the resourceName entry can contain multiple components.
Structures
The and structures contain:
typedef struct {
unsigned int size;
caddr_t addr;
} XrmValue, *XrmValuePtr;
typedef enum {
XrmoptionNoArg, /* Value specified in
XrmOptionDescRec.value */
XrmoptionIsArg, /* Value is the option string */
XrmoptionStickyArg, /* Value is characters immediately
following option */
XrmoptionSepArg, /* Value is next argument in argv */
XrmoptionResArg, /* Resource and value in next argument
in argv */
XrmoptionSkipArg, /* Ignore option and next argument
in argv */
XrmoptionSkipLine, /* Ignore option and the rest of argv */
XrmoptionSkipNArgs /* Ignore option and the next
XrmOptionDescRec.value arguments
in argv */
} XrmOptionKind;
typedef struct {
char *option; /* Option specification string in
argv */
char *specifier; /* Binding and resource name
(without application name) */
XrmOptionKind argKind; /* Which style of option it is */
caddr_t value; /* Value to provide if XrmoptionNoArg
or XrmoptionSkipNArgs */
} XrmOptionDescRec, *XrmOptionDescList;
See Also
XrmGetResource(3X11), XrmMergeDatabases(3X11), XrmPutResource(3X11), XrmUniqueQuark(3X11)
X Window System: The Complete Reference, Second Edition, Robert W. Scheifler and James Gettys
XrmInitialize(3X11)