2007-11-27 12:53:18 +00:00
|
|
|
#!/bin/sh
|
2007-10-26 22:44:33 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
function cexit {
|
|
|
|
if [ -d /tmp/tabedit.$$ ]; then
|
|
|
|
rm -rf /tmp/tabedit.$$;
|
|
|
|
fi
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
trap cexit 2 15
|
|
|
|
|
|
|
|
TABLE=$1
|
2008-01-26 17:55:34 +00:00
|
|
|
if [ -z "$TABEDITOR" ]; then
|
|
|
|
TABEDITOR=$EDITOR
|
|
|
|
fi
|
|
|
|
if [ -z "$TABEDITOR" ]; then
|
|
|
|
#echo "WARNING: Define TABEDITOR or EDITOR environment variable before running this command"
|
|
|
|
TABEDITOR=vi
|
2007-10-26 22:44:33 +00:00
|
|
|
fi
|
|
|
|
if [ -z "$TABLE" ]; then
|
|
|
|
echo "Usage: tabedit <tablename>";
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
mkdir -p /tmp/tabedit.$$/
|
|
|
|
xcatclientnnr tabdump $1 > /tmp/tabedit.$$/$1.csv
|
|
|
|
#use md5sum to check if it actually changes..
|
|
|
|
SUM=`md5sum /tmp/tabedit.$$/$1.csv`
|
|
|
|
EXIT=0
|
|
|
|
while [ $EXIT -eq 0 ]; do
|
|
|
|
cd /tmp/tabedit.$$
|
2008-01-26 17:55:34 +00:00
|
|
|
"$TABEDITOR" $1.csv
|
2007-10-26 22:44:33 +00:00
|
|
|
cd -
|
|
|
|
NEWSUM=`md5sum /tmp/tabedit.$$/$1.csv`
|
|
|
|
if [ "$NEWSUM" == "$SUM" ]; then
|
|
|
|
echo "No file modifications detected, not restoring."
|
|
|
|
break;
|
|
|
|
fi
|
|
|
|
if `dirname $0`/tabrestore /tmp/tabedit.$$/$1.csv; then
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
echo "Above errors occured, hit enter to edit, or ctrl-c to abort"
|
|
|
|
read JNK
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
cexit
|
|
|
|
|