Hi all,
I am trying to set up some variables in a shell script. The variables contain values of various paths needed to run a java module. The problem is the variables dont seem to be setting at all.
here is what i am trying to do :
JAR_HOME=/home/was5/bdcms/scheduledjobs/lib
export... (1 Reply)
The following seems quite basic but does not seem to work. Anybody know why?
$ g=1
$ echo $g
1
$ echo abc$g
abc1
$ abc$g=hello
ksh: abc1=hello: not found
$ echo $abc1
ksh: abc1: parameter not set
It works when I specify the full variable name
$ abc1=hello
$ echo $abc1
hello
... (2 Replies)
Hello everybody,
I am having problem in converting byte array variables to Hexa String variables for Linux. I have done, converting byte array variables to Hexa String variables for Windows but same function doesn't work for linux. Is there any difference in OS ? The code for Windows is given... (2 Replies)
Dear all, today I'm scratching my head with a simple (I believe) issue.
Working with date is quite simple, so if I Need to add some seconds to current time, I'll use:
date --date='+30 seconds' +"%Y-%m-%d %H:%M:%S"But, how to pass the value to add from a variable? I tried the following without... (2 Replies)
Hi All,
i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way??
#!/bin/ksh
##script is sample.ksh
age=$1
gender=$2
class=$3
.
.
.... (3 Replies)
Example:
while read line
do
stat -c %G $line
done < somefile.txtThe problem is that inside somefile.txt lines can have any symbol allowed as file name, like (). Even with spaces, it splits the words.
somefile.txt:dira/my first jump.avi
dirb/surf video (1080p).mkv (2 Replies)
If i do below command in unix prompt which static values (ie 27..97), it is working fine and gives desired output
>ls -d $WORKDIR/batch/somefilename_{27..97}.* 2>/dev/null
somefilename_27.sometxt
somefilename_28.sometxt
somefilename_29.sometxt
..
somefilename_97.sometxt
But if i want... (2 Replies)
Discussion started by: haiderali
2 Replies
LEARN ABOUT OPENDARWIN
shlock
SHLOCK(1) BSD General Commands Manual SHLOCK(1)NAME
shlock -- create or verify a lock file for shell scripts
SYNOPSIS
shlock -f lockfile [-p PID] [-u] [-v]
DESCRIPTION
The shlock command can create or verify a lock file on behalf of a shell or other script program. When it attempts to create a lock file, if
one already exists, shlock verifies that it is or is not valid. If valid, shlock will exit with a non-zero exit code. If invalid, shlock
will remove the lock file, and create a new one.
shlock uses the rename(2) system call to make the final target lock file, which is an atomic operation (i.e. "dot locking", so named for this
mechanism's original use for locking system mailboxes). It puts the process ID ("PID") from the command line into the requested lock file.
shlock verifies that an extant lock file is still valid by using kill(2) with a zero signal to check for the existence of the process that
holds the lock.
The -f argument with lockfile is always required.
The -p option with PID is given when the program is to create a lock file; when absent, shlock will simply check for the validity of the lock
file.
The -u option causes shlock to read and write the PID as a binary pid_t, instead of as ASCII, to be compatible with the locks created by
UUCP.
The -v option causes shlock to be verbose about what it is doing.
RETURN VALUES
A zero exit code indicates a valid lock file.
EXAMPLES
BOURNE SHELL
#!/bin/sh
lckfile=/tmp/foo.lock
if shlock -f ${lckfile} -p $$
then
# do what required the lock
rm ${lckfile}
else
echo Lock ${lckfile} already held by `cat ${lckfile}`
fi
C SHELL
#!/bin/csh -f
set lckfile=/tmp/foo.lock
shlock -f ${lckfile} -p $$
if ($status == 0) then
# do what required the lock
rm ${lckfile}
else
echo Lock ${lckfile} already held by `cat ${lckfile}`
endif
The examples assume that the filesystem where the lock file is to be created is writeable by the user, and has space available.
HISTORY
shlock was written for the first Network News Transfer Protocol (NNTP) software distribution, released in March 1986. The algorithm was sug-
gested by Peter Honeyman, from work he did on HoneyDanBer UUCP.
AUTHOR
Erik E. Fair <fair@clock.org>
BUGS
Does not work on NFS or other network filesystem on different systems because the disparate systems have disjoint PID spaces.
Cannot handle the case where a lock file was not deleted, the process that created it has exited, and the system has created a new process
with the same PID as in the dead lock file. The lock file will appear to be valid even though the process is unrelated to the one that cre-
ated the lock in the first place. Always remove your lock files after you're done.
BSD June 29, 1997 BSD