New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Help with a simple script


Post Reply New Thread Subscribe

 
Thread Tools
dgcrane

 
Member Since: Jul 11, 2013
Posts: 4
dgcrane is on a distinguished road

dgcrane is offline
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
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 7,433
Raz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant future
Mac Specs: 27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3

Raz0rEdge is offline
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.
QUOTE Thanks
dgcrane

 
Member Since: Jul 11, 2013
Posts: 4
dgcrane is on a distinguished road

dgcrane is offline
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
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 7,433
Raz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant future
Mac Specs: 27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3

Raz0rEdge is offline
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.
QUOTE Thanks
dgcrane

 
Member Since: Jul 11, 2013
Posts: 4
dgcrane is on a distinguished road

dgcrane is offline
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
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 7,433
Raz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant future
Mac Specs: 27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3

Raz0rEdge is offline
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.
QUOTE Thanks
dgcrane

 
Member Since: Jul 11, 2013
Posts: 4
dgcrane is on a distinguished road

dgcrane is offline
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
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 7,433
Raz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant future
Mac Specs: 27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3

Raz0rEdge is offline
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.
QUOTE Thanks

Post Reply New Thread Subscribe


« Visual Studio Expert. | Script Help to Silent Mounting Shares »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Running a Script For All Active Directory Users jmazzo OS X - Operating System 0 02-12-2013 10:55 AM
a simple move, select, delete applescript...with an award! tease OS X - Development and Darwin 0 04-09-2010 11:22 AM
Using CMS Made Simple with MAMP - Step-By-Step cuhnool Web Design and Hosting 4 02-08-2010 08:16 PM
Really Need Help Regarding MAC Script MACSCRIPT OS X - Apps and Games 2 08-13-2008 07:15 AM
Simple AppleScript request... 570thusaag Running Windows (or anything else) on your Mac 0 02-02-2006 12:33 PM

All times are GMT -4. The time now is 04:34 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?