Hello all,
I have a question. Please help me to populate an array with the arguments passing to a Shell scripts.
For example when I call "abc.sh a1 a2 a3" args (a1, a2, ...) recieved in an Array inside the abc.sh
arr = a1
arr = a2
and so on...
Thanks in advance, (2 Replies)
Hello ( sorry newbie question )
I don't understand something im trying to make simple alias that takes 1 arg but it don't gives me the desire result
here is what I have :
stlist | awk '{print "ls -l "$2}'
now I want to translate it to alias that takes instead of the $2 one arg
so I did : ... (4 Replies)
My program usage takes the form for example;
$ theApp 2 "one or more words"
i.e. 3 command line arguments; application name, an integer, some text
My code includes the following 4 lines:
int anInteger;
char words;
sscanf(argv, "%d", &anInteger);
sscanf(argv, "%s", &message);
Based... (2 Replies)
I am trying to print command line arguments one per second. I have this
while
do
echo "6"
shift
echo "5"
shift
echo "4"
shift
echo "3"
shift
echo "2"
shift
echo "1"
shift
done (2 Replies)
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 and it printed the value of $1 after every number. I don't want that I just want... (2 Replies)
Hey..
I've gotten inspired by another thread and used this:
#!/usr/bin/bash
args 2,5 $(<file.list)
It works but I'll like the results separated into different files or back into the 'used'/original files, whatever is easiest.
e.g. use fileA | args 2,5 > fileB or fileA and then do this to... (9 Replies)
Hello,
i have a problem. I must write a script, which wants 2 arguments.
for example:
./test.sh x.txt y.txtit must be write x.txt in y.txt
and when i give 1 or no argument like
/.test.sh x.txtmust this give a error message like: SYNTAX <inputfile> <outputfile>
my solution is... (5 Replies)
Hi
I want to write a script which store all the parameters passed to the script into an array.
Once it is stored I want scan through the array and and delete those files for last month present inside the directory. The files in directory is appneded with YYYY_MM_DD.
I want to know how can I... (3 Replies)
I am trying to write a simple shell script that will take certain arguments (numerical values) and plug each one into a nawk command.
I thought I would need to use for args x y z but i get syntax errors:
for args 16 1 3 25 31 41
do
nawk -F, '{if($10==$ &&... (8 Replies)
Heya
Tooltip: Parsing (getopts) for -u successfully sets mode=umnt, but case umnt is not executed,
instead it either executes/show help or regular mount screen.
I had copy pasted the structure of a getopts 'structure' from Man Page for getopts (posix Section 1) - The UNIX and Linux Forums... (1 Reply)
Discussion started by: sea
1 Replies
LEARN ABOUT HPUX
xtsetarg
XtSetArg() XtSetArg()
Name
XtSetArg - set a resource name and value in an argument list.
Synopsis
void XtSetArg(arg, resource_name, value)
Arg arg;
String resource_name;
XtArgVal value;
Inputs
arg Specifies the Arg structure to set.
resource_name
Specifies the name of the resource.
value Specifies the value of the resource, or its address.
Description
XtSetArg() sets arg.name to resource_name, and sets arg.value to value. If the size of the resource is less than or equal to the size of
an XtArgVal, the resource value is stored directly in value; otherwise, a pointer to it is stored in value.
XtSetArg() is implemented as the following macro:
#define XtSetArg(arg, n, d) ((void)( (arg).name = (n), (arg).value = (XtArgVal)(d) ))
Because this macro evaluates arg twice, you must not use an expression with autoincrement, autodecrement or other side effects for this
argument.
Usage
Many Intrinsics functions need to be passed pairs of resource names and values in an ArgList to set or override resource values. XtSe-
tArg() is used to set or dynamically change values in an Arg structure or ArgList array.
Note that in Release 4, a number of functions beginning with the prefix XtVa were added to the Intrinsics. These functions accept a NULL-
terminated variable-length argument list instead of a single ArgList array. Often these forms of the functions are easier to use.
Example
XtSetArg() is usually used in a highly stylized manner to minimize the probability of making a mistake; for example:
Arg args[20];
int n;
n = 0;
XtSetArg(args[n], XtNheight, 100); n++;
XtSetArg(args[n], XtNwidth, 200); n++;
XtSetValues(widget, args, n);
Incrementing the array index on the same line means that resource settings can be easily read, inserted, deleted or commented out on a
line-by-line basis. If you use this approach, be careful when using XtSetArg() inside an if statement-don't forget to use curly braces to
include the increment statement.
Alternatively, an application can statically declare the argument list:
static Args args[] = {
{XtNheight, (XtArgVal) 100},
{XtNwidth, (XtArgVal) 200},
};
XtSetValues(Widget, args, XtNumber(args));
Structures
The Arg and ArgList types are defined as follows:
typedef struct {
String name;
XtArgVal value;
} Arg, *ArgList;
The definition of XtArgVal differs depending on architecture-its purpose is precisely to make code portable between architectures with dif-
ferent word sizes.
See AlsoXtMergeArgLists(1), XtNumber(1).
Xt - Argument Lists XtSetArg()