Author Topic: Need Mac Guru  (Read 1624 times)

Offline drax0r

  • Major FANTASTIC Member
  • *******
  • Posts: 3433
  • Muckraker Extraordinaire
    • Anna Texas Community Forum
Re: Need Mac Guru
« Reply #30 on: September 11, 2009, 04:41:40 PM »
Everything I say, do, imply, or infer is the sole representation and responsibility of the individual who owns this account and does not represent the opinion, policy, position, or intent of any organization or other entity, public or private.

Offline ehowton

  • Colonel COURAGEOUS Member
  • *********
  • Posts: 7595
  • Fingering the Muse
    • http://ehowton.livejournal.com
Re: Need Mac Guru
« Reply #31 on: September 11, 2009, 04:49:50 PM »

Offline filmnazi

  • Full Member
  • ***
  • Posts: 142
  • libertarian whipping boy
Re: Need Mac Guru
« Reply #32 on: September 11, 2009, 04:51:50 PM »
I don't know much about applescript, but I'd reckon you could put the bash stuff into a file like getweather.sh and then chmod +x that file and then have applescript call "open /path/to/getweather.sh"

You might want to make the first line of your script #!/bin/bash (or the output of the command "which bash") whichever is more accurate. :)

Ok, so I'm a complete novice with the use of the terminal.  I can change directories and list their contents but that is about the extent of my knowledge.

So, how do I go about placing the bash stuff into a file? As for your second suggestion, what does the #! mean?

Offline ehowton

  • Colonel COURAGEOUS Member
  • *********
  • Posts: 7595
  • Fingering the Muse
    • http://ehowton.livejournal.com
Re: Need Mac Guru
« Reply #33 on: September 11, 2009, 04:59:54 PM »
So, how do I go about placing the bash stuff into a file? As for your second suggestion, what does the #! mean?

Read up on vi.

#! says basically, "Yo, I'm a script."


Offline filmnazi

  • Full Member
  • ***
  • Posts: 142
  • libertarian whipping boy
Re: Need Mac Guru
« Reply #34 on: September 11, 2009, 05:04:14 PM »

Read up on vi.

#! says basically, "Yo, I'm a script."



sorry, but I am a total newb-vi stands for?

Offline Angi

  • Captain Awesome Member
  • ******
  • Posts: 1316
  • Yes, I sell Tupperware.
    • Tupperware!
Re: Need Mac Guru
« Reply #35 on: September 11, 2009, 05:17:15 PM »
Wow. Flashback to my Unix classes.

I may have to try this applescripting on my Mac. Sounds like fun, and I may get some of my geek cred back.  ;)
Visit my Tupperware site at: http://my.tupperware.com/AngelaRingland

Offline drax0r

  • Major FANTASTIC Member
  • *******
  • Posts: 3433
  • Muckraker Extraordinaire
    • Anna Texas Community Forum
Everything I say, do, imply, or infer is the sole representation and responsibility of the individual who owns this account and does not represent the opinion, policy, position, or intent of any organization or other entity, public or private.

Offline ehowton

  • Colonel COURAGEOUS Member
  • *********
  • Posts: 7595
  • Fingering the Muse
    • http://ehowton.livejournal.com
Re: Need Mac Guru
« Reply #37 on: September 11, 2009, 06:15:08 PM »
cron

no

Automate.  Everything.

It's meant to be interactive. 

You're not usually that subjective.  In *my* perfect world, I'd have it tell me on the hour, every hour, the weather.

Offline ehowton

  • Colonel COURAGEOUS Member
  • *********
  • Posts: 7595
  • Fingering the Muse
    • http://ehowton.livejournal.com
Re: Need Mac Guru
« Reply #38 on: September 11, 2009, 06:15:33 PM »

Read up on vi.

#! says basically, "Yo, I'm a script."



sorry, but I am a total newb-vi stands for?

Nothing.  Its a text editor.

Offline drax0r

  • Major FANTASTIC Member
  • *******
  • Posts: 3433
  • Muckraker Extraordinaire
    • Anna Texas Community Forum
Re: Need Mac Guru
« Reply #39 on: September 11, 2009, 09:29:53 PM »

Read up on vi.

#! says basically, "Yo, I'm a script."



sorry, but I am a total newb-vi stands for?

Nothing.  Its a text editor.

First there was "ed" - it was short for editor.  Then there was a visual editor - they called it 'vi' for visual.
Everything I say, do, imply, or infer is the sole representation and responsibility of the individual who owns this account and does not represent the opinion, policy, position, or intent of any organization or other entity, public or private.

Offline filmnazi

  • Full Member
  • ***
  • Posts: 142
  • libertarian whipping boy
Re: Need Mac Guru
« Reply #40 on: September 11, 2009, 09:33:06 PM »
I was just afraid that if I put just two letters into google I might end up reading about the wrong thing! but, number one on the list is a very informative wiki article....

Ok so I decided that i wanted a txt file as output so that I could add additional strings in applescript before issuing the say command.  So now drax's script looks like this: 

echo > speakableweather.txt `wget --quiet -O - "http://rss.weather.com/weather/rss/local/75409?cm_ven=LWO&cm_cat=rss&par=LWO_rss"| grep "more details" |grep img|awk -F">" '{print $3}'|sed s/"For more details"//g|sed 's/&deg/degrees/g'|awk -F";" '{print $1}'`

This works fine in terminal but if i try to run the script using the do shell script command in applescript I get a command not found error.  I think this is because, according to it's documentation applescript always uses /bin/sh to interpret commands. I think this is a different shell than bash right? Can I add the necessary commands to /bin/sh?

Offline ehowton

  • Colonel COURAGEOUS Member
  • *********
  • Posts: 7595
  • Fingering the Muse
    • http://ehowton.livejournal.com
Re: Need Mac Guru
« Reply #41 on: September 11, 2009, 10:06:32 PM »
I was just afraid that if I put just two letters into google I might end up reading about the wrong thing! but, number one on the list is a very informative wiki article....

Ok so I decided that i wanted a txt file as output so that I could add additional strings in applescript before issuing the say command.  So now drax's script looks like this: 

echo > speakableweather.txt `wget --quiet -O - "http://rss.weather.com/weather/rss/local/75409?cm_ven=LWO&cm_cat=rss&par=LWO_rss"| grep "more details" |grep img|awk -F">" '{print $3}'|sed s/"For more details"//g|sed 's/&deg/degrees/g'|awk -F";" '{print $1}'`

This works fine in terminal but if i try to run the script using the do shell script command in applescript I get a command not found error.  I think this is because, according to it's documentation applescript always uses /bin/sh to interpret commands. I think this is a different shell than bash right? Can I add the necessary commands to /bin/sh?

Ok - I'm on my mac now; word-for-word what is your syntax in the applescript gui?

Offline filmnazi

  • Full Member
  • ***
  • Posts: 142
  • libertarian whipping boy
Re: Need Mac Guru
« Reply #42 on: September 11, 2009, 10:18:35 PM »
do shell script "openhd:users:myusername:unixstuff:scripts:getweather.sh"

I used cat > getweater.sh to make the file in terminal then i did the chmod +x getweather.sh

chmod +x makes it executable right?

Offline ehowton

  • Colonel COURAGEOUS Member
  • *********
  • Posts: 7595
  • Fingering the Muse
    • http://ehowton.livejournal.com
Re: Need Mac Guru
« Reply #43 on: September 11, 2009, 10:19:27 PM »
chmod +x makes it executable right?

Ayep.

Offline filmnazi

  • Full Member
  • ***
  • Posts: 142
  • libertarian whipping boy
Re: Need Mac Guru
« Reply #44 on: September 11, 2009, 10:44:54 PM »
Ok I know this has got to be one of the simplest things to do in terminal, but give me a hint anyway, ok? How do I run the .sh file in order to test it?