Skip to main content
deleted 23 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 238

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.

thanks for any help.

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.

thanks for any help.

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.

edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265
Source Link

Ambigious redirect error on different volumes with mysql

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.

thanks for any help.