Environment
Open Enterprise Server
Novell Client 2 SP3 for Windows
Situation
A user may see an application error indicating that a file is "stuck" open/locked. The System Administrator wants to identify which workstation has the file open and locked and clear the lock.
Resolution
Run the following script from a terminal on the OES server to identify the user who is holding the file open, and attempt to close the file.
#!/bin/bash
FILE=$1
if [[ -z "$FILE" ]]
then
echo "Error: Missing file path argument"
exit
fi
if [[ -e $FILE ]]
then
/sbin/ncpcon files list f=${FILE} 2>/dev/null | grep -i "No open locks were found on the file" >/dev/null
if (( $? != 0 ))
then
echo "Attempting to close file -- $FILE"
/sbin/ncpcon files list f=${FILE}
/sbin/ncpcon files close f=${FILE} >/dev/null
else
echo "File not open -- $FILE"
fi
else
echo "Error: File not found -- $FILE"
fi
For example, copy the lines above to a script file named close_file.sh, then use the file to close a file in the current directory named myfile.txt by typing the following command line:
./close_file.sh myfile.txt