Unable to run bash scripts

Discussion in 'Mac Programming' started by amanszab, Dec 6, 2007.

  1. amanszab macrumors newbie

    Joined:
    Dec 6, 2007
    #1
    My issue is that my computer is not recognizing bash terminal scripts. I type in the name of the script, hit return, and nothing happens. No errors arise. Any suggestions?
     
  2. ChrisA macrumors G4

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #2
    How do you know it is not working? Silly question but it is hard to know what is wrong when all you say it "it don't work". Could you try making a small two line script, post the script here and tell us what happens. The more information you can give the better. But do keep your example script down to as small as possible.
     
  3. KidneyPi macrumors member

    Joined:
    Dec 6, 2007
    #3
    Is the script you want to run in your path? If so, unless you are in the same directory as the script, you do have a problem. If you are in the same directory as the script, put a ./ at the front of the filename. You could also type the complete path to the script.

    To see your path, type: echo $PATH
     
  4. savar macrumors 68000

    savar

    Joined:
    Jun 6, 2003
    Location:
    District of Columbia
    #4
    If the script wasn't in the path, bash would return an error. The OP didn't see any error message.

    The script is executing, it's just not doing what the OP wants it to do.
     
  5. CaptainZap macrumors regular

    Joined:
    Jan 17, 2007
    #5
    Permissions possibly? I'm not sure what a script does if the permissions aren't set right.
     
  6. ChrisA macrumors G4

    Joined:
    Jan 5, 2006
    Location:
    Redondo Beach, California
    #6
    The shell would print "Permission denied"

    My guess is that this guy's script runs just fine put it just does not print anything so he thinks it's not running.
     
  7. KidneyPi macrumors member

    Joined:
    Dec 6, 2007
    #7
    Good point. Is this a script that came with the system? Did the OP write it? Maybe the OP could post the script or a link to it.

    Many new *nix users get tripped up by the fact that many programs don't put output on STDOUT (the terminal display). Unless the script is meant to pass output to another program or to be written to a file, there is often no output.
     
  8. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #8
    have you tried redirecting stderr to sdout? That is, in the bash shell:

    ./scriptname 2>1
     

Share This Page