/bin/bash event not

Discussion in 'Mac Basics and Help' started by atira, Apr 29, 2013.

  1. atira macrumors newbie

    Joined:
    Apr 29, 2013
    #1
    Hi

    please help me...

    I'm trying to run a script written by a friend:

    #!/bin/bash

    for aStat in ....

    do
    ....
    done

    when coping the script to the terminal I get:


    /bin/bash: Event not found.

    for: Command not found.
    do: Command not found.

    I read the post http://forums.macrumors.com/showthread.php?t=1072580
    however when coping into terminal:
    export PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"

    I got:
    export: Command not found.

    what am I doing wrong?

    Thanks alot!
     
  2. r0k macrumors 68040

    r0k

    Joined:
    Mar 3, 2008
    Location:
    Detroit
    #2
    Let's run a couple of quick tests in terminal.

    1) In a fresh new terminal, type "which bash"

    It should come back with /bin/bash

    #!/bin/bash is the normal start for any script as it starts a new shell to run the rest of the script.

    As for your problems with for xx in yy do done, I suggest an sh, csh or bash tutorial, many of which are freely available on the web. The unix command line is powerful but picky. The shell expands * to every file in your current folder, so if you were in a folder full of 99 text files,

    for f in *.txt do
    cat $f
    done

    would type out the contents of all 99 files one by one. However the example I'm including here might not work literally as I have typed it. You may need some quotes in there around certain elements to get it to do what you expect.

    Here is an example I found near the top googling "for do done":

    Code:
    #!/bin/bash
    for file in /etc/*
    do
    	if [ "${file}" == "/etc/resolv.conf" ]
    	then
    		countNameservers=$(grep -c nameserver /etc/resolv.conf)
    		echo "Total  ${countNameservers} nameservers defined in ${file}"
    		break
    	fi
    done
     

Share This Page