Sample script
The following sample script parses the output of the p4
fstat
command to report files that are opened where the
head revision is not in the client workspace (a potential problem):
Example
#!/bin/sh
# Usage: opened-not-head.sh files
# Displays files that are open when the head revision is not
# on the client workspace
echo=echo
exit=exit
p4=p4
sed=sed
if [ $# -ne 1 ]
then
$echo "Usage: $0 files"
$exit 1
fi
$p4 fstat -Ro $1 | while read line
do
name=`$echo $line | $sed 's/^[\. ]\+\([^ ]\+\) .*$/\1/'`
value=`$echo $line | $sed 's/^[\. ]\+[^ ]\+ \(.*\)$/\1/'`
if [ "$name" = "depotFile" ]
then
depotFile=$value
elif [ "$name" = "headRev" ]
then
headRev=$value
elif [ "$name" = "haveRev" ]
then
haveRev=$value
if [ $headRev != $haveRev ]
then
$echo $depotFile
fi
fi
done