07-30-2014
Thanks you so much bakunin, we had our eid celebrations yesterday, that's why I'm posting late. I have changed my shell into bash so I think life will be a little bit easier even for a newbie like me. Thanks again and eid mubarak
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
What am I doing wrong with this foreach loop?
foreach var ($argv)
@sum = $sum + $var (4 Replies)
Discussion started by: haze21
4 Replies
2. Shell Programming and Scripting
Hi Guys,
I have a loop which uses a wildcard
i.e. foreach f (*)
but when I execute the tcsh file in unix then it gives me an error
->>>>>>>foreach: words not parenthesized<<<<<<<<<<-
Any help. (1 Reply)
Discussion started by: abch624
1 Replies
3. Shell Programming and Scripting
Hi everyone
Does anyone know what is wrong with this script. i keep getting errors
foreach filename (`cat testing1`)
set string=$filename
set depth=`echo "$string"
echo $depth
end
the error is the following
testing: line 1: syntax error near unexpected token `('
testing: line 1:... (3 Replies)
Discussion started by: ROOZ
3 Replies
4. Shell Programming and Scripting
I have a foreach loop in a csh script and I noticed that it tries to find the files with the pattern *$searchpt* in the file name. I'm confused as I never specified checking for the files.
foreach f ( *$searchpt* )
set fnew = `echo $f | awk -v searchpat=$searchpt \
... (1 Reply)
Discussion started by: kristinu
1 Replies
5. Shell Programming and Scripting
Hey all,,
I know cshell is harmful:) but I am using this just "to know" - for educational purposes!... not for a long-term use.
lets say i have a list..
set arr=(x y z e f)
I wanna iterate the list with foreach ,, not with while.!!
foreach i $arr
echo $i
end
does not work (2 Replies)
Discussion started by: eawedat
2 Replies
6. UNIX for Dummies Questions & Answers
Hello all,
I'm working on a foreach loop to compare a couple sets of data. However, each datafile includes a header row. I'm wondering if it is possible to tell the foreach loop to skip the first line of data.
I've been using the basic code as follows:
foreach line ("`file.csv`")
set... (2 Replies)
Discussion started by: meteorologistks
2 Replies
7. UNIX for Dummies Questions & Answers
I am trying to make a script for my Counter-Strike: Source servers. What i am wanting it to do is for it to restart each server, the only way i can think of doing this in through for each.
Years what i have at the moment.
server_start() {
START=`ps x | grep SCREEN | grep $SRV | cut -d '?' -f... (5 Replies)
Discussion started by: grahamn95
5 Replies
8. Shell Programming and Scripting
Dear all,
I wrote a script to download files and move files in directories according to their name.
Now here is the problem:
Both p101 and p360 data download successfully, but when I move them according to the year and month, only p101 data can be placed at the right location, p360,... (1 Reply)
Discussion started by: handsonzhao
1 Replies
9. UNIX for Dummies Questions & Answers
Hi everyone I'm new to unix and encountered a small problem i couldnt find out a reason why it doesn't work..please help..
in my csh script when i tried to use the foreach loop like this:
foreach x ( ls )
echo $x
end
when i tried to run it, it printed out 'ls' to the std out instead of... (3 Replies)
Discussion started by: ymc1g11
3 Replies
10. Shell Programming and Scripting
Just started shell scripting for the first time today :D Can anyone tell me why I get the error "foreach: Words not parenthesized." for my following code? The program takes in a list of arguments.
foreach card ($argv)
echo Hello
end (3 Replies)
Discussion started by: pkuebler
3 Replies
LEARN ABOUT OPENSOLARIS
sysevent_post_event
sysevent_post_event(3SYSEVENT) System Event Library Functions sysevent_post_event(3SYSEVENT)
NAME
sysevent_post_event - post system event for applications
SYNOPSIS
cc [ flag... ] file... -lsysevent -lnvpair [ library... ]
#include <libsysevent.h>
#include <libnvpair.h>
int sysevent_post_event(char *class, char *subclass, char *vendor,
char *publisher, nvlist_t *attr_list, sysevent_id_t *eid);
PARAMETERS
attr_list pointer to an nvlist_t, listing the name-value attributes associated with the event, or NULL if there are no such attributes
for this event
class pointer to a string defining the event class
eid pointer to a system unique identifier
publisher pointer to a string defining the event's publisher nam
subclass pointer to a string defining the event subclass
vendor pointer to a string defining the vendor
DESCRIPTION
The sysevent_post_event() function causes a system event of the specified class, subclass, vendor, and publisher to be generated on behalf
of the caller and queued for delivery to the sysevent daemon syseventd(1M).
The vendor should be the company stock symbol (or similarly enduring identifier) of the event posting application. The publisher should be
the name of the application generating the event.
For example, all events posted by Sun applications begin with the company's stock symbol, "SUNW". The publisher is usually the name of the
application generating the system event. A system event generated by devfsadm(1M) has a publisher string of devfsadm.
The publisher information is used by sysevent consumers to filter unwanted event publishers.
Upon successful queuing of the system event, a unique identifier is assigned to eid.
RETURN VALUES
The sysevent_post_event() function returns 0 if the system event has been queued successfully for delivery. Otherwise it returns -1 and
sets errno to indicate the error.
ERRORS
The sysevent_post_event() function will fail if:
ENOMEM Insufficient resources to queue the system event.
EIO The syseventd daemon is not responding and events cannot be queued or delivered at this time.
EINVAL Invalid argument.
EPERM Permission denied.
EFAULT A copy error occurred.
EXAMPLES
Example 1 Post a system event event with no attributes.
The following example posts a system event event with no attributes.
if (sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS", "SUNW", argv[0],
NULL), &eid == -1) {
fprintf(stderr, "error logging system event
");
}
Example 2 Post a system event with two name-value pair attributes.
The following example posts a system event event with two name-value pair attributes, an integer value and a string.
nvlist_t *attr_list;
uint32_t uint32_val = 0XFFFFFFFF;
char *string_val = "string value data";
if (nvlist_alloc(&attr_list, 0, 0) == 0) {
err = nvlist_add_uint32(attr_list, "uint32 data", uint32_val);
if (err == 0)
err = nvlist_add_string(attr_list, "str data",
string_val);
if (err == 0)
err = sysevent_post_event(EC_PRIV, "ESC_MYSUBCLASS",
"SUNW", argv[0], attr_list, &eid);
if (err != 0)
fprintf(stderr, "error logging system event
");
nvlist_free(attr_list);
}
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Evolving |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
SEE ALSO
devfsadm(1M), syseventd(1M), nvlist_add_boolean(3NVPAIR), nvlist_alloc(3NVPAIR), attributes(5)
SunOS 5.11 26 May 2004 sysevent_post_event(3SYSEVENT)