I am trying to set up a variable based on the name of the file.
function script_name {
if
then
job_name='MONITOR'
return job_name;
elsif
then
job_name='VERSION'
return job_name
fi
}
for i in `ls *log`
do
script_name $i
done. (4 Replies)
I'm trying to create a directory from my Perl script. Only if the there was an error I want to let the user know about it. So if the folder exists is ok.
This is what I think should work:
`mkdir log 2>/dev/null`;
if($? == 0 || $? == errorCodeForFileExists)
{ everyting is fine }
else
{... (3 Replies)
hi
i have a file, i am reading line by line and checking a line contains a string ,
`grep "Change state" $LINE`
if
then
echo "The line contains---"
else
echo "The line does not contains---"
i need to check the return code , but i am getting an error
... (4 Replies)
hi friends ,
i need c code for my app,
in my app the user can create the new user for the system,
while creating the new user ,i try to include the condition
the user name is not present in password.
my exe requrment is : the user name char is not present in password,if the password... (6 Replies)
I have a short line of code that checks very rudimentary for duplicate code:
sort myfile.cpp | uniq -c | grep -v "^.*1 " | grep -v "}"
It sorts the file, counts occurrences of each line, removes single occurrences and removes the ubiquitous closing brace. The language is C++, but is easily... (3 Replies)
Hi, (i'm sorry for my english)
I'm a problem on boot sco unix 5.0.5 open server.
this stop at "Checking protected password and checking subsystem databases"
(See this image )
I'm try this:
1) http://www.digipedia.pl/usenet/thread/50/37093/#post37094
2) SCO: SCO Unix - Server hangs... (9 Replies)
#!/bin/ksh
#This script will check status of load balancer in AIX servers from hopbox
#Steps to do as folows :
#Login to server
#netstat -ani | grep <IP>
#check if the output contains either lo0 OR en0
#if the above condition matches, validation looks good
#else, send an email with impacted... (7 Replies)
Hi,
I am writing the shell script in ksh to check certain no of files exists,In my case there are 7 files exist like below
Sales1_timstamp.csv
Sales2_timstamp.csv
Sales3_timstamp.csv
Sales4_timstamp.csv
Sales5_timstamp.csv
Sales7_timstamp.csv
Sales7_timstamp.csv
Once all the files... (4 Replies)
Discussion started by: SRPR
4 Replies
LEARN ABOUT MOJAVE
shlock
SHLOCK(1) BSD General Commands Manual SHLOCK(1)NAME
shlock -- create or verify a lock file for shell scripts
SYNOPSIS
shlock [-du] [-p PID] -f lockfile
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 link(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 -d option causes shlock to be verbose about what it is doing.
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.
EXIT STATUS
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 file system where the lock file is to be created is writable 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.
AUTHORS
Erik E. Fair <fair@clock.org>
BUGS
Does not work on NFS or other network file system 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