List:General Discussion« Previous MessageNext Message »
From:Peng Yu Date:October 9 2011 10:19pm
Subject:Why the same command have different results when it is in a bash
script and when it is not?
View as plain text  
Hi,

It is seems strange to me why the same command "mysql -hlocalhost
-uxxx" when it is run from the command line, it will show an error.
When it is run in a bash script, it runs fine. I guess this might be
described somewhere, but I'm yet to find the answer. Does anybody know
why this happens and how to make the command line version working?

~$ mysql -hlocalhost -uxxx
ERROR 1045 (28000): Access denied for user 'xxx'@'localhost' (using
password: YES)
~$ cat `which mysqllocalhostxxx.sh `
#!/usr/bin/env bash

mysql -hlocalhost -uxxx
~$  mysqllocalhostxxx.sh
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 101
Server version: 5.5.9 Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>


-- 
Regards,
Peng
Thread
Why the same command have different results when it is in a bashscript and when it is not?Peng Yu10 Oct
  • Re: Why the same command have different results when it is in a bash script and when it is not?Rik Wasmus10 Oct
  • Re: Why the same command have different results when it is in a bash script and when it is not?Johan De Meersman11 Oct