i want to import a database with mysql (running with MAMP):
#! /bin/bash
# variables
currdir=$PWD
dbname=TEST
dbuser=root
dbpass=root
dbpath="/applications/MAMP/Library/bin"
exname=database
if [ "$1" = "import" ]
then
cd $dbpath
./mysql -u $dbuser -p$dbpass $dbname < $currdir/$exname.sql
fi
if my script and files are on a different volume as the mysql bin i get an
line 31: $currdir/$exname.sql: ambiguous redirect
error, if they are on the same volume the import works. is it a permission error? echoing all variables give values, they are not empty, also first reading the file into a variable with
value=$(<$exname.sql)
does not work, though $value holds the contents of the file? is it the cd? i tried to run mysql directly without the cd:
# cd $dbpath
/applications/MAMP/Library/bin/mysql -u (...)
but it also does not work.
<
, like this"$currdir/$exname.sql"
. If it expands to more than one word, bash reports an error. – Stefan Hamcke Jan 03 '19 at 13:08$PWD
has a space character @Kusalananda – Stefan Hamcke Jan 03 '19 at 13:11