(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



Mailbag: bashrc broken, can't login



Author: TonyLawrence
Date: Thu Mar 10 11:57:05 2005
Subject: Mailbag: bashrc broken

Someone sent me email (don't do that if you aren't a customer - post here) with this problem:


 
Seems like none of the standard commands are working on my terminal 
 
It logs me in ok with my welcome screen but up top it reads 
 
Last login: Wed Mar  2 10:56:54 on ttyp1 
Welcome to Darwin! 
-bash: export: `/bin:/sbin:/usr/bin:/usr/sbin': not a valid identifier 
-bash: export: `/usr/local/mysql/bin:': not a valid identifier 
My-Computer:~ user$ 
 
What lead to this problem is when I was trying to install mysql on
my powermac G4, I was going off of a book of instructions from mac
OS X web development book, everything was going find up until the
last few instructions then it error msg
 
ERROR 1064 (42000): You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the
right syntax to use near 'PRIVILEGES ON *.* TO mysql@localhost
IDENTIFIED BY 'mypassword'' at line 1
mysql> 
 
It began to get messy before the error msg concerning bash when on
step 9 where the command is
 
Echo 'export PATH=/usr/local/mysql/bin: $PATH' >> ~/.bashrc 
 
I wasn't sure if I was even suppose to do this because I think I
already have bash and tcshrc on my mac
 
It followed by having me to a touch .bash_profile then ls -Ga l to
see the list which it did but then Doing .~/.bashrc ENV=$HOME/.bashrc
export ENV it got messy again and when it asked to save :w
apparently that command meant to sort and it continued to get messy
not sure what it actually did
 
I managed to still find my way to step 10 and it seem to accept
password but then that's when the error msg appeared
 
Currently, anytime I try to enter a command it reads 
 
-bash: command not found even to list directory still not working 
 
Not sure where to go from here any ideas ? 
 
Thank you for your time basically no commands work in the terminal
all i get is this

Welcome to Darwin!
-bash: export: `/bin:/sbin:/usr/bin:/usr/sbin': not a valid identifier 
-bash: export: `/usr/local/mysql/bin:': not a valid identifier 
I'm using mac os x 10.3.7 
 


What's happened is that's he's messed up his .bash_profile and possibly .bashrc



I can't really tell why from the mail; possibly bad quoting (" or ` vs ' in following the directions), but it doesn't really matter. Do this



/bin/mv .bash_profile oldbash_profile
/bin/mv .bashrc oldbashrc

Or use Finder to rename these graphically..

then logout and log in again. Figure out what happened, fix it and put 'em back.




Click here to add your comments





Fri Mar 11 02:21:29 2005: Subject:   anonymous


that code worked perfectly thanks my terminal is accepting comands now thanks again, now i feel guilty sorry for sending it through the email



Fri Mar 11 13:03:54 2005: Subject:   TonyLawrence

gravatar
There's no reason to feel guilty - you offered to pay for an answer. I just knew this was simple, and more importantly could be useful to other people, so it should be a public post.

I'll answer questions here if I think the subject can be of value to other people, so why not try for a free answer first?





Sun Apr 10 17:06:57 2005: Subject:   anonymous




The problem was the space between the new path elements and $PATH. Shell assignments (FOO=bar:baz:quux) can't have spaces in them without being quoted (nor do you want your path to have a space in it), so bash did this:

  • Set PATH to /usr/local/mysql/bin
  • Export PATH
  • Try to export the variable named whatever the contents of $PATH are--in other words, the contents of PATH, which would be the previous contents, if I recall the order of shell evaluation correctly--which isn't the name of a variable, so bash gave the
    export: not a valid identifier
    warning




FWIW, the
export
command flags a variable for export to subshells. It doesn't snapshot the current value, and it doesn't require the value to be specified on that line (although that syntax is permitted in some shells).



For portability, clarity, and ease of debugging, I'd prefer to see that .bashrc snipped rewritten like this:



PATH=/usr/local/mysql/bin:$PATH 
# PATH is already exported--no need to export it again




which has the added advantage that if the extra-space-before-$PATH typo had been made using this syntax, it would have raised an error on the assignment line and isolated it from the export command, which wasn't really the problem.



Sun Apr 10 17:10:43 2005: Subject: HTML tags in my post   anonymous




>Oh, lovely; all my HTML tags are visible in my post, because I entered them in capital letters just like the posting instructions say. How hideous.



Sun Apr 10 18:55:16 2005: Subject:   TonyLawrence

gravatar
Sorry - forgot /i I'll fix..



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar


ad


Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


book graphic unix and linux troubleshooting guide

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!



 I sell and support
 Kerio Mail server




pavatar.jpg
More:
       - Forum
       - Shell


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress