14.04 - Problem on run mysql with arguments from own script - Ask Ubuntu
i have installed xubuntu 16.04 , mysql 5.7 server.
i create simple script name mysql-wrapper
:
#!/bin/bash mysql -u myuser -pmypwd mydatabase --table $*
now run command , execute successfully:
mysql-wrapper -e "status"
then try run next command (with space):
mysql-wrapper -e "show tables"
i problem: mysql print me commands, run mysql illegal command.
how can solve issue? or may better use alias?
in ordinary usage, shouldn't have reason using plain $*
. should using "$@"
(note quotes included):
#!/bin/bash mysql -u myuser -pmypwd mydatabase --table "$@"
only "$@"
script arguments pe passed as-is command, safe field splitting , globbing.
to see difference, run script containing
#!/bin/bash printf "%s\n" $* printf "%s\n" $@ printf "%s\n" "$*" printf "%s\n" "$@"
with various arguments.
Comments
Post a Comment