Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bingefeller

macrumors 6502a
Original poster
Jun 25, 2007
605
38
Northern Ireland
Hi guys,

I know very little about scripts and programming so how would I go about this..

I have my IRC log file - /apple/users/Macbookpro/Chat Logs/Rooms/chat.log

How could I run a script that would run the grep command on that chat.log file to search for imgur links and then download any images that were posted?
 
On OS X, the preferred method is launchd agents:
http://launchd.info

If you write the script you want, or use something like Automator to create one, launchd uses an XML file to tell it how to run it periodically. Or you can use something like Lingon to create the XML for you:
https://www.peterborgapps.com/lingon/

And if you're new to scripting, I might suggest looking at something like Python to write your script, rather than shell scripting...
 
AppleScript looks like a good friend here.
You can run shell commands using the "do shell script" command.
Take a look at this script (copied from http://macscripter.net/viewtopic.php?id=39724):
Code:
repeat 10 times
   say "Small Guy says Hi!"
   delay 1
endrepeat
"delay 1" tells the AppleScript interpreter to wait 1 second before continuing.
 
I'd strongly recommend the launchd method that Analog Kid mentioned.

Cron will work, but is the 'old' method and Apple recommends launchd instead. I suspect that means that cron will be deprecated at some point in the future. Whether that happens or not, you'll find launchd much more flexible. There's a good tutorial here:

http://nathangrigg.net/2012/07/schedule-jobs-using-launchd/

The AppleScript method would mean that the script would wait one second after completion of the script before running again. So, if your script took 5 mins to run then the interval would be 5 mins and one second. That may or may not be a problem for you.
 
  • Like
Reactions: Analog Kid
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.