Hi, this is my first post so here goes.....
I need help... I am trying to write a script to produce some stats based on a number of searches in a log file. Now i know how to do this using multiple variables which are really just greps, but I want a more efficent way of doing this as my poor... (1 Reply)
I'm using perl to do a grep of each line in a vendor file and find its occurrences in a specific directory. Any values found is saved in @dir.
.....(file opened, etc.)
....
while ($line=<FILE>){
@dir = `grep $line * `;
}
It's the specific usage of the system grep that I'm having... (7 Replies)
OK here's the situation:
I have got these lines which I have got to parse.
If the line contains a particular string and any element from a previously defined array I need to take that particular line and do some further processing.
if ((grep(/$_/,$1)) && (grep($pattern,@myarr)))
{
#Do... (2 Replies)
Hello
I want to grep a line from a file saved in some directory.
Can anyone please correct the code below:
#!/usr/bin/perl -w
$file = "/home/output.txt"
$grep_line = "closing zip for topic";
`grep $grep_line* $file`; (1 Reply)
Hi All i have this script that uses glob to look in /var/log/messages.*
my @messagefiles = glob "/var/log/messages.*";
and the code that uses it is this
grep { /NVRM: Xid/ } @messages)
but this spits out this
/var/log/messages-20111030:Oct 25 13:43:04 brent kernel: NVRM:... (10 Replies)
Im storing multiple functions in a varaible called $check...
The variable check contains the following:
a()
b()
c()
...
..etc
now im checking individually which function is kept in which file using GREP
if ( grep \$check \i, <FILE> )
The problem is im getting the output for the... (1 Reply)
Hi,
Can anybody let me know how this grep will work.
The input and output is not known.
Also can you give me the details of any link where i can find clearly about grep
Thanks in advance (1 Reply)
hello Everyone i am a newbie.
i have a file which contains the following
E:\gtmproj\script\i486_nt\obj\check_geomtools.exe: o:\portsrc\spg\system_1\i486_nt\advapps\TK-2\objmt\winclockmtq.lib
E:\gtmproj\script\i486_nt\obj\check_geomtools.exe:... (12 Replies)
I have an file which have data in lines as follows
ad, findline=24,an=54,ab=34,av=64,ab=7989,ab65=34,aj=323,ay=34,au=545,ad=5545
ab,abc,an10=23,an2=24,an31=32,findline=00,an33=23,an32=26,an40=45,ac23=5,ac=87,al=76,ad=26... (3 Replies)
Discussion started by: deepKrish
3 Replies
LEARN ABOUT DEBIAN
cmutex
CMUTEX(3) Common Library Functions CMUTEX(3)NAME
Cmutex - LCG Mutex inferface
SYNOPSIS
#include <Cmutex.h>
void Cmutex_init(int (*lockroutine)(void *addr, int timeout), int (*unlockroutine)(void * addr));
int Cmutex_lock(void *addr, int timeout);
int Cmutex_unlock(void *addr);
DESCRIPTION
Cmutex is a common API interface for application compiled or not with the multithread flag. If the application do never initialize the Cmu-
tex package, using Cmutex_init, and two arguments that are the addresses of the mutex lock and unlock functions, lockfunction and unlock-
function respectively, then all Cmutex calls are dummy operations.
Otherwise any call to Cmutex_lock will raise a call to lockfunction , and any call to Cmutex_unlock will raise a call to unlockfunction.
Please note that the Cmutex package is initially meant to be interfaced with Cthread only.
Cmutex_lock takes as argument the address addr of anything that is static in your userspace, such as a 'static int variable;' address (see
EXAMPLE section below), and a timeout expressed in second unit.
If timeout is lower than zero, the operation will block until the mutex is granted. If it is zero, the operation will try to have the
mutex and immediately return, possibly with failure. If it is greater than zero, operation will exit if the timeout is reached. Please
refer to Cthread_mutex_timedlock description in the Cthread man page.
Return code of Cmutex_lock is 0 if success, -1 on failure. If failure the serrno error code is set appropriately.
Cmutex_unlock releases a lock that you previously gained using Cmutex_lock and the same address value addr.
Return code is 0 if success and -1 on failure, error code is then in the serrno variable.
ERRORS
If the Cthread interface is chosen and activated, the errors value are in the serrno variable:
SECTHREADINIT
LCG Thread interface initialization error
A thread initialisation call failed. In principle, on UNIX this will be a call to pthread_mutex_init (and possibly pthread_mutex-
attr_init) that failed, on Windows/NT this might be a call to CreateMutex.
SECTHREADERR
LCG Thread interface failure in calling your thread library
A thread call to your native system library (like the pthread one on UNIX) failed. Please note that this is differentiated to the
Cthread initialization and can happen if you are using too much thread keys, for example. This is really a run-time error only con-
cerning your operating system thread interface. Any other system call failure, but not a thread one, and not at the initialisation
step, will set serrno to SEINTERNAL
SEOPNOTSUP
Operation not supported
This can be generated only if you compiled Cthread with a -DCTHREAD_PROTO flag that Cthread do not know about. Check your LCG con-
figuration site.def.
SEINTERNAL
Internal error
You can have more information by compiling the Cthread package with the flag -DCTHREAD_DEBUG, and catching the printout on your
stderr stream. This is any system call that failed (like malloc()), except those to the thread library (for which SECTHREADERR or
SECTHREADINIT is to be found), or any critical internal run-time error (such as a non correct value found in some Cthread internal
structures).
SETIMEDOUT (routines with a timeout parameter only)
Timed out
You called a routine with a timeout value greater than zero that reached the maximum number of timeout seconds in waiting state.
EINVAL
Invalid parameters
You called a routine with invalid parameter(s). Please check your code.
EDEADLK
Deadlock
Mutex is already locked by the calling thread (PTHREAD_MUTEX_ERRORCHECK mutexes only, this is not the default and should not happen
via Cmutex)
EBUSY
Device or resource busy
Mutex is already locked by another thread.
EPERM
Permission denied
Mutex is now owned by the calling thread (PTHREAD_MUTEX_ERRORCHECK mutexes only, this is not the default and should not happen via
Cmutex)
EXAMPLE
/*
* Here follows an example. The call to Cthread_init routine shows
* that multi-threaded mode is explicitly activated by the application
* (you will then have to link with the thread library). Neverthless,
* you can very well call some other external library, and leave as it is
* the Cmutex calls.
*/
#include <Cmutex.h>
#include <Cthread_api.h>
#include <serrno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <log.h>
int this;
extern int Cthread_debug;
int main() {
Cthread_init(); /* Comment this and Cmutex calls will become dummy */
initlog("testit",LOG_INFO,"");
if (Cmutex_lock(&this,10) != 0) {
fprintf(stderr,"### Cmutex_lock (%s)
",sstrerror(serrno));
}
if (Cmutex_unlock(&this) != 0) {
fprintf(stderr,"### Cmutex_unlock (%s)
",sstrerror(serrno));
}
}
SEE ALSO
Cthread, serrno
AUTHOR
LCG Grid Deployment Team
LCG $Date: 2010-04-05 09:51:26 +0200 (Mon, 05 Apr 2010) $ CMUTEX(3)