05-09-2013
Thanks for the reply, if you can give a small example how to use it ,that will help me a lot.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
In my script I use this command \c when printing(echo) out statements but this only works in the Korn Shell(ksh).
I need the same command to be used in the Bash Shell, is there one out there?
Thanks,
the A. (1 Reply)
Discussion started by: Astudent
1 Replies
2. Shell Programming and Scripting
Hi,
I have written below check lockfile script but need some tweaking on it.
If there is a lockfile from present, I need the script to retry every 10 seconds to see if the lockfile is still there. After 120 seconds it should send an email.
In my current version, if the script encounters... (6 Replies)
Discussion started by: Meert
6 Replies
3. Shell Programming and Scripting
Just tried out the following code from "Using lockfiles in shell scripts":
#!/bin/bash
if ; then
echo "File exists"
else
echo "File does not exists. Create file now."
echo 1 > number.txt
fi
lockfile script.lock
a=$(/usr/bin/tail -n 1 number.txt)
if ; then... (1 Reply)
Discussion started by: courteous
1 Replies
4. AIX
Server: IBM p770
OS: AIX 6.1 TL5 SP1
When one of our develoeprs types "bash" on the command line to switch shells, it hangs. For some reason, two bash processes are created....the first bash process spawns a second bash process in the same console, causing a hang. Anyone have any idea what... (2 Replies)
Discussion started by: wjssj
2 Replies
5. UNIX for Dummies Questions & Answers
I'm reading about debugging aids in bash and have come across the set command. It says in my little book that an addition to typing
set
you can also use them "on the command line when running a script..." and it lists this in a small table:
set -o option Command Line... (5 Replies)
Discussion started by: Straitsfan
5 Replies
6. UNIX for Advanced & Expert Users
Hi all,
I have to test some user priviliges. The goal is to be sure that an unauthorized user can't restart some modules (ssh, mysql etc...).
I'm trying to automate it with a shell script but in same cases I got the syslog broadcast message.
Is there any way to simply get a return code... (3 Replies)
Discussion started by: Dedalus
3 Replies
7. Shell Programming and Scripting
I created a script that I need to run from time to time, but get this error message. To get it working again I run this command from time to time:
export PATH="$PATH:~/scripts"
I put all my automated scripts in the /scripts directory and would like to run my scripts from any directory... (5 Replies)
Discussion started by: catalinawinemxr
5 Replies
8. UNIX for Advanced & Expert Users
Hi,
I have a process which can run one instance at a time. Currently we have multiple scripts trying to kickoff this process. I wanted to implement the semaphore mechanism to achieve this.
I was going through few examples. The below code seems to be reasonable solution.
... (5 Replies)
Discussion started by: tostay2003
5 Replies
9. Shell Programming and Scripting
The below command moves all the .vcf files into the directory.
cp /home/cmccabe/Desktop/test/vcf/overall/stats/*.vcf /home/cmccabe/Desktop/NGS/annovar
When I use a bash wrapper the target.txt gets created but the text files do not get copied. All the paths are the same, but not sure why... (2 Replies)
Discussion started by: cmccabe
2 Replies
10. Shell Programming and Scripting
How to run several bash commands put in bash command line without needing and requiring a script file.
Because I'm actually a windows guy and new here so for illustration is sort of :
$ bash "echo ${PATH} & echo have a nice day!"
will do output, for example:... (4 Replies)
Discussion started by: abdulbadii
4 Replies
LEARN ABOUT REDHAT
flockfile
LOCKFILE(3) Linux Programmer's Manual LOCKFILE(3)
NAME
flockfile, ftrylockfile, funlockfile - lock FILE for stdio
SYNOPSIS
#include <stdio.h>
void flockfile(FILE *filehandle);
int ftrylockfile(FILE *filehandle);
void funlockfile(FILE *filehandle);
DESCRIPTION
The stdio functions are thread-safe. This is achieved by assigning to each FILE object a lockcount and (if the lockcount is nonzero) an
owning thread. For each library call, these functions wait until the FILE object is no longer locked by a different thread, then lock it,
do the requested I/O, and unlock the object again.
(Note: this locking has nothing to do with the file locking done by functions like flock(2) and lockf(3).)
All this is invisible to the C-programmer, but there may be two reasons to wish for more detailed control. On the one hand, maybe a series
of I/O actions by one thread belongs together, and should not be interrupted by the I/O of some other thread. On the other hand, maybe the
locking overhead should be avoided for greater efficiency.
To this end, a thread can explicitly lock the FILE object, then do its series of I/O actions, then unlock. This prevents other threads from
coming in between. If the reason for doing this was to achieve greater efficiency, one does the I/O with the non-locking versions of the
stdio functions: with getc_unlocked() and putc_unlocked() instead of getc() and putc().
The flockfile() function waits for *filehandle to be no longer locked by a different thread, then makes the current thread owner of *file-
handle, and increments the lockcount.
The funlockfile() function decrements the lock count.
The ftrylockfile() function is a non-blocking version of flockfile(). It does nothing in case some other thread owns *filehandle, and it
obtains ownership and increments the lockcount otherwise.
RETURN VALUE
The ftrylockfile() function returns zero for success (the lock was obtained), and nonzero for failure.
ERRORS
None.
AVAILABILITY
These functions are available when _POSIX_THREAD_SAFE_FUNCTIONS is defined. They are in libc since libc 5.1.1 and in glibc since glibc 2.0.
CONFORMING TO
POSIX.1
SEE ALSO
unlocked_stdio(3)
2001-10-18 LOCKFILE(3)