Terminal won't login (does seperate script)

Discussion in 'Mac Programming' started by noahgolm, Dec 4, 2010.

  1. macrumors member

    Joined:
    Aug 18, 2010
    #1
    Hi, I was making a simple bash script which showed hidden files in finder, and apparently something went wrong. I tried to move the file into the /bin folder to make it executable without the ./, but i don't know if that's what is wrong here. It seems that whenever I open terminal now, it tries to run that script, then displaying the "process complete" line and staying there. I had quit the script once in the middle of it, and heard this can happen sometimes because of that. Is there any way of fixing this? I tried deleting the com.apple.Terminal.plist file, but it did no good...
     
  2. macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #2
    From the Finder, Click the Go menu and Go to Folder option. Put /bin or /usr/bin (whichever folder you made your script in) and click Go. Move your script to either the Trash or out of that folder to the Desktop or something.

    Now when you start up the Terminal, it will give you an error until you remove the reference to the script from whichever file you put it in, but at least your terminal will load.

    You could also tell Terminal to start with /bin/zsh instead of the default shell, but that would only work if you had put your reference to your broken script in once of the bash specific files like bashrc or bash_profile
     
  3. thread starter macrumors member

    Joined:
    Aug 18, 2010
    #3
    Aaaagh! I just looked at the /bin/bash script in my text editor, and its contents are the script I made! It's running that instead of the normal bash! Is there any way to restore this?
     
  4. ulbador, Dec 4, 2010
    Last edited: Dec 4, 2010

    macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #4
    Ouch! You messed up.. What Mac OS version and computer type are you on? You are going to have to replace that it with the proper binary. Otherwise you'll have to switch from bash to zsh or something

    I could send you my bash binary, but that will only work if you are on Snow Leopard.

    I've attached it. Double click it to unzip and drag it to your /bin directory.
     

    Attached Files:

  5. thread starter macrumors member

    Joined:
    Aug 18, 2010
    #5
    Well, I'm running Snow Leopard on a late 2008 Macbook. With a little bit of specifics, I'm running 10.6.4, have a 160GB hardrive, and 2GB of RAM. And a screwed up bash script. Thank you!
     
  6. macrumors 68000

    ulbador

    Joined:
    Feb 11, 2010
    #6
    I edited my last post and attached a zip file containing that bash file. We appear to be on the same OS version
     
  7. thread starter macrumors member

    Joined:
    Aug 18, 2010
    #7
    Thank you so much! You're a real lifesaver here. Works just fine now!
     
  8. macrumors 65816

    Joined:
    Sep 19, 2009
    #8
    Case in point of why the command line can be dangerous. You simply have to pay attention to what you are doing where. Use the pwd command liberally! Common commands like ls conveniently echo $PWD automatically.
     
  9. subsonix, Dec 5, 2010
    Last edited: Dec 5, 2010

    macrumors 68040

    Joined:
    Feb 2, 2008
    #9
    Good to hear that it went well in the end. It's never a good idea to store your own scripts in /bin or other reserved places for os binaries. Use /usr/local/bin or your own purpose made folder that you then add to the PATH environment variable.
     
  10. macrumors 65816

    Joined:
    Sep 19, 2009
    #10
    This.

    I have my own bin in my home folder. Simply make one, and add this to your .bash_profile:

    Code:
    export PATH=$PATH:$HOME/bin
     

Share This Page