Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
iwlock return code
System
Hi,
iwlock is always returning no success even when it is successfully locking the file. I am using following syntax -
my $success = `iwlock vpath comment`;
but $success is always false even if the file is being locked successfully.
I am using TS 6.1 on Solaris.
Thanks for you suggestion.
-PB
Find more posts tagged with
Comments
Migrateduser
Check $? after calling iwlock.
Adam Stoller
As John indicated - you need to check the return status - not return text (which is what your code is trying to do, and which is futile since iwlock doesn't return anything on STDOUT, but it does on STDERR).
Unfortunately, iwlock doesn't differentiate between an error of permission versus an error of already-being-locked - so you need to do something a bit more complex like this:
my $result = qx($iwhome/bin/iwlock $vpath "comment"
2>&1
);
if ($?){
# there was an error of some sort
if ($result !~ /^ERROR:00017/){
# ignore "file is already locked or assigned" error
# do something regarding error
}
}
The
2>&1
forces STDERR to get redirected to STDOUT, which then gets captured in
$result
. The
ERROR:00017
was determined by running the command in a shell to verify what happens if you try to lock the same file multiple times (note:
iwunlock
is even worse because if you try to unlock a file twice you get "
ERROR:00920: Object being looked up was not found
" - which is misleading, and no different than the error you get if the file doesn't actually exist - I filed a bug on this a long time ago, don't remember the number though).
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com