Minor exception checking and safer path handling added.

This commit is contained in:
tomas 2005-05-19 14:28:07 +00:00
parent 974ecc10a0
commit 24dee2cc65
2 changed files with 13 additions and 9 deletions

View file

@ -22,7 +22,7 @@
# #
# #
# Author : $Author: tomas $ # Author : $Author: tomas $
# Version : $Revision: 1.1 $ # Version : $Revision: 1.2 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/Attic/import.sh,v $ # Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/Attic/import.sh,v $
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -70,12 +70,13 @@ while true; do
case "$1" in case "$1" in
-d|--directory) -d|--directory)
srcdir=$2; srcdir=$2;
srcabsdir=`cd "$srcdir"; pwd`
shift; shift;; shift; shift;;
-l|--list) -l|--list)
filelist=$2; filelist=$2;
filelistbasename=`basename $filelist` filelistbasename=`basename "$filelist"`
filelistdir=`dirname $filelist` filelistdir=`dirname "$filelist"`
filelistabsdir=`cd $filelistdir; pwd` filelistabsdir=`cd "$filelistdir"; pwd`
filelistpathname=$filelistabsdir/$filelistbasename filelistpathname=$filelistabsdir/$filelistbasename
shift; shift;; shift; shift;;
-h|--help) -h|--help)
@ -91,7 +92,7 @@ while true; do
esac esac
done done
if [ "x$srcdir" == "x" -a "x$filelist" == "x" ]; then if [ "x$srcabsdir" == "x" -a "x$filelist" == "x" ]; then
echo "Directory or filelist option required."; echo "Directory or filelist option required.";
printUsage; printUsage;
exit 1; exit 1;
@ -104,11 +105,13 @@ fi
cd $phpdir cd $phpdir
if [ -f "$filelistpathname" ]; then if [ -f "$filelistpathname" ]; then
cat $filelistpathname | php -q import.php || exit 1 cat "$filelistpathname" | php -q import.php || exit 1
fi fi
if [ -d "$srcdir" ]; then if [ -d "$srcabsdir" ]; then
find "$srcdir" -type f | php -q import.php || exit 1 find "$srcabsdir" -type f | php -q import.php || exit 1
else
echo "Warning: not a directory: $srcabsdir"
fi fi
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------

View file

@ -23,7 +23,7 @@
Author : $Author: tomas $ Author : $Author: tomas $
Version : $Revision: 1.1 $ Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/php/Attic/import.php,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/bin/php/Attic/import.php,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -39,6 +39,7 @@ require_once '../../var/GreenBox.php';
#PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n"); #PEAR::setErrorHandling(PEAR_ERROR_PRINT, "%s<hr>\n");
PEAR::setErrorHandling(PEAR_ERROR_RETURN); PEAR::setErrorHandling(PEAR_ERROR_RETURN);
$dbc = DB::connect($config['dsn'], TRUE); $dbc = DB::connect($config['dsn'], TRUE);
if(PEAR::isError($dbc)){ echo "ERROR: ".$dbc->getMessage()." ".$dbc->getUserInfo()."\n"; exit(1); }
$dbc->setFetchMode(DB_FETCHMODE_ASSOC); $dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = &new GreenBox($dbc, $config); $gb = &new GreenBox($dbc, $config);