12-23-2019
Do you want to create the "lock" in perl or in shell?
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I have used exec ("/bin/ksh -c /path/file.ksh arg1"); to execute the file.ksh script from a test.pl script. But it doesnt work.. can anyone tell me what exactly the systax should be?... i have tried system("/path/file.ksh arg1"); too....still no luck...
quick replies are highly appreciated (1 Reply)
Discussion started by: meghana
1 Replies
2. UNIX for Dummies Questions & Answers
Hello evreyone,
this is my first post, and to say i'm new to this is an understatement.
I know very little about perl scripts and hope some one can help me.
i'm looking to get a script that a cron job can execute.
what the script needs to to is
1) connect to a mysql database
2) go to a... (2 Replies)
Discussion started by: Exader
2 Replies
3. Shell Programming and Scripting
hi guys,
i have a query, i wrote a perl script that will collect cpu statistics
Scripts/myScripts/
cpu.pl
i want to make this file so that i can run it from any location on any drive,
without giving the path explicitly.
like
$/home/ravi/perl
cpu.pl
i tried this... (8 Replies)
Discussion started by: niteesh_!7
8 Replies
4. Shell Programming and Scripting
Hi Folks,
I have created a script last month to retrive files thru FTP and cronjob was running fine till yesterday. But the naming convention of the daily file is Filename_<date>.xml
where date is YYYYMMDD. But today i have received file name as Filename_20110232.xml :(
Part of my Perl... (4 Replies)
Discussion started by: Sendhil.Kumaran
4 Replies
5. Shell Programming and Scripting
Am trying to lean perl scripting in Unix OS to automate my tasks.
Please find the below perl script i have tried
#!/usr/bin/perl -w
print "Please Enter the VG name to be checked:";
$A = <>;
print "Please Enter the free size to be checked in GB:";
$B = <>;
$vgcheck = `vgdisplay... (7 Replies)
Discussion started by: jayachandran87
7 Replies
6. Programming
Hi
I have a bash script which takes parameters
sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC
gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash
I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies
7. Shell Programming and Scripting
I want to check access rights permissions not for 'user', not for 'group', but for 'others'.
I want to do it by system command in which i want to use 'ls -l' and 'awk' command.
I have written the following program :
#!/usr/bin/local/perl
#include <stdlib.h>
system ("ls -l | awk... (1 Reply)
Discussion started by: shubhamsachdeva
1 Replies
8. Shell Programming and Scripting
hi All,
i have to modify a shell script written in Perl. i have to use execute immediate within this. i have to create a temporary table but it should have name like ar_data_$mmyyyy , how can i achieve this?
any help on this would be highly appriciated. (6 Replies)
Discussion started by: lovelysethii
6 Replies
9. Shell Programming and Scripting
Hello
Can some help with write part of perl script
I need something like this in perl
SSH="/bin/ssh -o BatchMode=yes -o"
USER="test"
SRV="server"
SCRIPT_TO_EXEC="/tmp/test.sh" -> shell script
OUT=/tmp/out.file
${SSH} -l ${USER} ${SRV} 'sudo /usr/bin/ksh -s' < ${SCRIPT_TO_EXEC} >> ${OUT}... (1 Reply)
Discussion started by: vikus
1 Replies
10. Programming
I have reviewed many examples on-line about running another process (either PERL or shell command or a program), but do not find any usefull for my needs way. (Reviewed and not useful the system(), 'back ticks', exec() and open())
I would like to run another PERL-script from first one, not... (1 Reply)
Discussion started by: alex_5161
1 Replies
LEARN ABOUT NETBSD
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