I think I typed some bad unix :(

bunner bob

Registered
I was configuring MySQL using Marc Liyanage's instructions and, though I'm on Panther and should have been in the bash shell, it turns out i was in the tcsh shell.

I was trying to set up the shortcut so I didn't have to type the whole directory path when I wanted to issue a command to mysql. I copied and pasted a line of code (viewed as source). The line was supposed to include a couple of ">>" signs, but in code they read ">>" - so here's the transcript:

[whitebox:~] bob% echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile
[1] 876
[2] 877
tcsh: gt: Command not found.
tcsh: /Users/bob/.bash_profile: Command not found.
[whitebox:~] bob% export PATH=/usr/local/mysql/bin:$PATH
tcsh: gt: Command not found.

[2] + Exit 1 ( ; gt )
[1] + Done echo export PATH=/usr/local/mysql/bin:$PATH

So I hit return (hoping I hadn't done damage) and entered it in the right way (or what would have been had this been a bash shell):

[whitebox:~] bob% echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile

But when I ran this:

[whitebox:~] bob% mysql test
tcsh: mysql: Command not found.

At which point I realized I'd been using the command for the wrong shell, so I entered this:

[whitebox:~] bob% echo 'setenv PATH /usr/local/mysql/bin:$PATH' >> ~/.tcshrc

Which should have been fine but this still didn't work:

[whitebox:~] bob% mysql test
tcsh: mysql: Command not found.


Though I WAS able to run the command by entering the full path name.

So what DID I do? And can I undo it? And actually get the shortcut to work?


Thanks, O Unix masters.

- Bob
 
Firstly, you don't need to use Marc's tools, since MySQL is actually available as an Installer package directly from http://www.mysql.com/downloads/mysql-4.0.html

I believe that package runs an installer script that adds mysql binaries to the $PATH, but I'm not 100% sure.

Now you have to make a decision: which shell do you want to use, bash or tcsh? I personally prefer tcsh, but most people don't as far as I can see. In either event, edit a plain text file in your home folder called either .tcshrc or .bashrc and add a line like the following
setenv PATH "${PATH}:/usr/local/mysql/bin"
This will append /usr/local/mysql/bin to the end of whatever your existing PATH is. Note that other files can set other path elements after that one, but for our purposes the order of path elements doesn't matter one bit. Path elements are separated by a : and do not take a trailing slash.

I'm a tcsh-er so I don't now exactly what ~/.bash_profile does, but the .___rc means run-command, and is run when you log in to that shell (whatever the blank is). So you can have .tcshrc .cshrc .bashrc .shrc that are run each time you log in to a shell, in the same way you have /etc/rc for boot-time run commands.

By the way, > is an HTML escape sequence for the > (also known as the greater-than operator, which is where the gt comes from). If you ever see something like that in your code in the shell, change it to what it should really look like, not the HTML escapes.
 
.bash_profile is for bash what .profile is to sh/ksh. They use .bash_profile so sh/ksh doesn't get pissed if you run them and have bash commands that aren't compatible with sh/ksh in .profile.

Brian
 
Back
Top