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)
file locked?
MattP
the CLT iwlockinfo provides some useful information...
Name: b_delete.asp
Area: default
Assignor: ncc_americas\petitjm
Assignee: ncc_americas\petitjm
State: Locked
Time Stamp: [Wed Jul 09 13:41:51 2003]
Comments: Locked by launching edit.
How do get just the state of the lock? What I want to do is in an IF statement, check if the file is locked first. Any ideas?
Thanks
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
Find more posts tagged with
Comments
JonathonG
use iwattrib and the istagged attribute
> iwattrib MyLockedFile istagged
TRUE
> iwattrib MyUnlockedFile istagged
FALSE
Jonathon
Interwoven Architecture Consultant
MattP
nice. works, thanks.
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
MattP
I guess in reality, it doesn't return the *string* TRUE or FALSE. I am trying to perfom conditional logic based on the file being lock, but my if statement fails...
$islocked = `iwattrib $wa$global_file istagged`;
if ($islocked eq "TRUE")
{
$temp = "The file is locked";
}
elsif ($islocked = "FALSE")
{
$temp = "The file is not locked";
}
else
{
$temp = "undetermined";
}
When I print out $islocked and $temp, $islocked is either TRUE or FALSE and $temp is always undertermined.
I have tried a few different iteration, including if ($islocked)
Any ideas?
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
Migrateduser
I don't understand why you don't use iwlockinfo. I think it should return OS exit code 0 if the file is locked, 1 if it is not locked.
MattP
how do you get JUST the state? All of the iwlockinfo attributes are listed in the first post...
Thanks
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
Migrateduser
I have a subroutine like this:
#--------------------------------------------------------------------
# Subroutine: Execute( command, results )
# First Parameter: The command to execute.
# Second Parameter: Reference to a hashtable to pass back results.
# Returns: Operating system exit code of command.
# Purpose: Return HTML to send to a browser to cause it
# to redirect to a different page.
# In the Hashtable:
# cmd - the command executed.
# ret - Operating System exit code of the command.
# err - Operating System error message from the command.
# out - STDOUT and STDERR from the command.
#--------------------------------------------------------------------
sub Execute( $$ )
{
my ( ${cmd} ) = shift(
@_
);
my $results = shift(
@_
);
my ${out} = `${cmd} 2>&1`;
my ${ret} = $?;
my ${err} = $!;
chomp( ${out} );
${results}->{'cmd'} = ${cmd};
${results}->{'ret'} = ${ret};
${results}->{'err'} = ${err};
${results}->{'out'} = ${out};
${results}->{'msg'} = ${results}->{'cmd'} . " returned " . ${results}->{'ret'} . " :\n" . ${results}->{'out'};
return( ${ret} );
}
That I call with code like this:
my %results = ();
CMSIdeas:
ysUtil::Execute( "iwlockinfo /ridiculously/long/path/to/file", \%results );
I can then check ${results{'ret'}} - it should contain the zero/nonzero flag. But you could do it without the subroutine by just checking $? after calling iwlockinfo. I really don't know the difference between system, exec, backticks, etc (I find that backticks work best for me).
MattP
Got it, thanks. I think I will stick with $? .
Thanks
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
JonathonG
The trouble is that the command is returning a newline. So, when you do an eq it fails because the actual string is "TRUE\n" or "FALSE\n"
Two solutions:
1) Strip off the newline: $islocked =~ s/\s*$//g;
2) [my choice] use a regex instead of eq:
if ($islocked =~ /TRUE/)
{
}
elsif ($islocked =~ /FALSE/)
{
}
Make sense?
Jonathon
Interwoven Architecture Consultant
MattP
Ahh, got it.... I tried chomping it, which I thought would have removed that. Right now I am using the $?. I may try that just so I understand what it was doing.
Thanks again
Matt
Matthew Petitjean
BOC Group
Murray Hill, NJ 07974 USA
JonathonG
chomp didn't work? hmm, that's odd. That regex is really just a safer form of chomp. Although it does remove multiple whitespace characters, so maybe there was more than one newline being returned. *shrug* The regex matching instead of eq should work though.
Jonathon
Interwoven Architecture Consultant