Results 1 to 8 of 8
  1. #1
    Help with a simple script

    Member Since
    Jul 11, 2013
    Posts
    4
    Help with a simple script
    Hello,

    I am having my first experience with a Mac for a media server I am trying to set up. Its going very well so far and working 98.5 % of the way I hoped for but I am hoping for some help with the last little bit.

    I have been trying to make my first shell script to do what I am doing manually in the terminal. I assumed it could be like a bat file and just click on it and it would execute my three little lines

    #!/bin/bash
    export USEPADEVICE="XMOS USB 2.0 Audio Out"
    export USEPAMAXSAMPLERATE=192000
    open ~/Applications/SqueezePlay.app
    exit

    I am running a headless 10.6.8 and I have saved these lines a file called SqueezePlay.sh under my home directory.

    Obviously, I got some problems, cause instead of executing, I get this :
    Last login: Thu Jul 11 15:43:03 on ttys000

    mac-mini:~ gena_mak$ ./SqueezePlay
    ./SqueezePlay: line 1: {rtf1ansiansicpg1252cocoartf1038cocoasubrtf360: command not found
    ./SqueezePlay: line 2: syntax error near unexpected token `}'
    ./SqueezePlay: line 2: `{\fonttbl\f0\fswiss\fcharset0 Helvetica;}'

    I tried putting the same information into an applescript and that didn't work out very well either LOL

    Thanks for any guidance you could give...

    Darren

  2. #2
    Help with a simple script
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    8,184
    Specs:
    27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3
    A couple of things, you saved the file as "SqueezePlay.sh", but are executing "SqeeuzePlay"?? Secondly, did you set the shell script to be executable by typing "chmod 755 SqueezePlay.sh" and then try typing "./SqueezePlay.sh"??
    --
    Regards
    ...Ashwin



    Be sure to read the Community Guidelines | The more information you provide, the better answers you get, remember GIGO.

  3. #3
    Help with a simple script

    Member Since
    Jul 11, 2013
    Posts
    4
    Thank you for the reply... I think I did what you said previously, but to be sure, I did it again.

    Last login: Thu Jul 11 15:52:11 on ttys000
    mac-mini:~ gena_mak$ ls
    Applications Downloads Music Sites
    Desktop Library Pictures SqueezePlay.sh
    Documents Movies Public
    mac-mini:~ gena_mak$ chmod 755 SqueezePlay.sh
    mac-mini:~ gena_mak$ ./squeezePlay.sh
    ./squeezePlay.sh: line 1: {rtf1ansiansicpg1252cocoartf1038cocoasubrtf360: command not found
    ./squeezePlay.sh: line 2: syntax error near unexpected token `}'
    ./squeezePlay.sh: line 2: `{\fonttbl\f0\fmodern\fcharset0 Courier;}'
    mac-mini:~ gena_mak$

    and this is what I get.....

    Darren

  4. #4
    Help with a simple script
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    8,184
    Specs:
    27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3
    Darren,

    Now I'm confused again..the file is called SqueezePlay.sh with a capital S, and you are executing squeezePlay.sh with a lowercase s. The command line is case sensitive..

    What program did you use to create this script file? Can you add "set -x" after the "#!/bin/bash" to see if you get any useful debug messages?
    --
    Regards
    ...Ashwin



    Be sure to read the Community Guidelines | The more information you provide, the better answers you get, remember GIGO.

  5. #5
    Help with a simple script

    Member Since
    Jul 11, 2013
    Posts
    4
    oops, that was my fault... I didn't know is was case sensitive. I have tried to execute twice more :

    ./Last login: Thu Jul 11 20:20:47 on ttys000
    mac-mini:~ gena_mak$ ./SqueezePlay.sh
    ./SqueezePlay.sh: line 1: {rtf1ansiansicpg1252cocoartf1038cocoasubrtf360: command not found
    ./SqueezePlay.sh: line 2: syntax error near unexpected token `}'
    ./SqueezePlay.sh: line 2: `{\fonttbl\f0\fmodern\fcharset0 Courier;}'

    mac-mini:~ gena_mak$ ./SqueezePlay.sh
    ./SqueezePlay.sh: line 1: {rtf1ansiansicpg1252cocoartf1038cocoasubrtf360: command not found
    ./SqueezePlay.sh: line 2: syntax error near unexpected token `}'
    ./SqueezePlay.sh: line 2: `{\fonttbl\f0\fmodern\fcharset0 Courier;}'
    mac-mini:~ gena_mak$

    Once with set -x on the same line as #!/bin/bash and once below because I didn't know if it made a difference... results were the same. I believe its called textedit on the mac to create the file.

    Darren

  6. #6
    Help with a simple script
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    8,184
    Specs:
    27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3
    Aha! You are not saving the file as a plain text file, you are saving it as a RTF file. I should've guessed with the "{rtf}" in your output..

    OK, in TextEdit, with the file open choose Format->Make Plain Text. Then save the file and run it and you should have better results..
    --
    Regards
    ...Ashwin



    Be sure to read the Community Guidelines | The more information you provide, the better answers you get, remember GIGO.

  7. #7
    Help with a simple script

    Member Since
    Jul 11, 2013
    Posts
    4
    The problem was the editor I used... It added a bunch of junk in the file. I opened it up with a tool called editrocket and I could see the problem immediately.

    all is working now and thanks for your effort and time.

    Darren

  8. #8
    Help with a simple script
    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    Location
    MA
    Posts
    8,184
    Specs:
    27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3
    That's correct, shell scripts need to be plain text to be executed by the shell (Bash in this case), whereas TextEdit by default chooses to create/safe files as Rich Text which gives you the flexibility to add formatting to text which is great for some reasons but not for this..

    So switching to Plain Text Mode would take care of the problem for you if you wish to use TextEdit again or if this editrocket program works, then that's fine too..
    --
    Regards
    ...Ashwin



    Be sure to read the Community Guidelines | The more information you provide, the better answers you get, remember GIGO.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. simple script works in 10.8.5 but doesn't work in 10.10.1
    By luckystone in forum OS X - Development and Darwin
    Replies: 0
    Last Post: 01-19-2015, 11:40 AM
  2. Shortcut or simple script help needed
    By martinielsen in forum OS X - Operating System
    Replies: 6
    Last Post: 07-24-2012, 07:18 PM
  3. Help with simple Automator file copy script
    By PBear in forum OS X - Apps and Games
    Replies: 0
    Last Post: 04-20-2012, 10:09 PM
  4. Simple rsync script advice, please
    By Seventh in forum OS X - Operating System
    Replies: 0
    Last Post: 07-29-2011, 04:05 PM
  5. I need a simple contact form script code
    By arron in forum Web Design and Hosting
    Replies: 7
    Last Post: 10-27-2009, 01:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •