Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Running shell scripts??

  • 19-02-2003 2:01pm
    #1
    Closed Accounts Posts: 1,325 ✭✭✭


    hey ppl,

    (im new to all this mac osx lark)

    Well iv written a shell script using BBEdit, thing is iv no idea what to do with it
    now. Iv been trying to get it to run using the run menu option in the #! drop down menu but it doesnt appear to do anything. I try the "run in terminal" option
    and that gives me an error (61).

    Iv checked the commands iv written into the script to see if it was those causing the problem but it doesnt appear to be that either.

    Iv saved the file as a .sh file and chmod +x on it but Im still baffled.

    Iv been googling and cannot find a decent page written about how to write shell
    scripts, ye know of any??

    Any ideas??
    A.


Comments

  • Registered Users, Registered Users 2 Posts: 2,010 ✭✭✭Dr_Teeth


    Why don't you just open up a terminal window, cd to where you've saved the script and go ./scriptname.sh ?

    Teeth.


  • Closed Accounts Posts: 1,325 ✭✭✭b3t4


    Yup Teeth hav tried that.

    It says command not found??
    Is there something that i need to do.

    The script im testing this with is the following

    #!/bin/tcsh
    mkdir /Users/Shared/FlatFiles

    Sorry if these are stupid questions.

    A


  • Closed Accounts Posts: 1,325 ✭✭✭b3t4


    Rite I found the problem.

    It dont appear that I can trust older people with some stuff. :D

    It shud be #!/bin/bash (doh!)

    Thanks,
    A.


  • Registered Users, Registered Users 2 Posts: 2,010 ✭✭✭Dr_Teeth


    Indeed. :)

    Teeth.


  • Closed Accounts Posts: 1,325 ✭✭✭b3t4


    Hmmm well i did say the prob was fixed but iv run into another one and cannot
    see why the following is happening.

    I have a couple of scripts written so far all of which work except for one.
    The one that isnt working is baffling me. It appears to be messing bout with
    the shebang line(learned something new today :) ). It can complete "/bin/bas"
    but spits out odd ASCII characters and then the "h" therefore it doesnt
    understand the command and ends before completing the script... This script is
    working fine until I want to run it in the terminal.

    Any ideas??
    A.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,010 ✭✭✭Dr_Teeth


    Could be a hidden char there that's messing things up. Try having a look at the script from inside the terminal - use 'cat scriptname.sh' and see if what comes out is correct.

    Teeth.


  • Closed Accounts Posts: 1,325 ✭✭✭b3t4


    I thought that as well Teeth. So I went along and copied the shebang line from
    the scripts that are working, that didnt work so I thought maybe the copy had a hidden char. So I then rewrote the shebang line. Saving all the way and testing to
    see if it was working. Still no joy.

    I tried the cat command on the file, as you suggested and it shows everything
    but the shebang line!!!! bit odd

    Iv compared the working scripts to the one not working and I cannot see any
    difference.

    A.


  • Registered Users, Registered Users 2 Posts: 2,010 ✭✭✭Dr_Teeth


    Weird.. try editing the script using a editor like pico or vi, to see if your gui editor is doing strange things. 'cat' should display everything in the file, if the shebang line is missing from its output then something is wrong somewhere.

    Teeth.


  • Closed Accounts Posts: 1,325 ✭✭✭b3t4


    It appears that the editor was the problem from the very start.

    #!/bin/bash and #!/bin/tcsh both work.

    Don't think Il be using BBEdit again.

    Thanks for your help,
    Much appreciated,
    A.


  • Registered Users, Registered Users 2 Posts: 430 ✭✭timod


    The problem is that BBedit can create 3 different type of text file (well not really a problem - it's exellent!)

    Windows/Mac/Unix use different encodings for line termination.

    To mark the end of a line in a text file the MacOS uses a carriage return (CR, ASCII 13), UNIX uses a line feed (LF, ASCII 10) while Windows uses a carriage return and a line feed (CRLF).

    When you wrote your initial script, the shell probably saw everything on the one line.

    In the bbedit window, there is a row of icons on top... the one that looks like a page, click it, and choose unix.
    Should do the trick for shell scripts.

    BBedit is excellent :)


  • Advertisement
Advertisement