Help with a simple script

Joined
Jul 11, 2013
Messages
4
Reaction score
0
Points
1
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
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
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"??
 
OP
D
Joined
Jul 11, 2013
Messages
4
Reaction score
0
Points
1
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
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
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?
 
OP
D
Joined
Jul 11, 2013
Messages
4
Reaction score
0
Points
1
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
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
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..:)
 
OP
D
Joined
Jul 11, 2013
Messages
4
Reaction score
0
Points
1
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
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
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..
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top