Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I want to write a script that searches a web page for an updated file, then downloading it when detected. There is no command I have found that does this, accept Automator's download URL function, that I believe just gets the HTML, not the file.

Tell me if I am wrong or if AppleScript can do such a task?

P.S. I would not like to use any Internet libraries.

share|improve this question

2 Answers 2

You have a couple options here, oh the power of a mac!

Option 1:

Use the curl command, documented here.

I would use AppleScript to run the Curl command and any other command you need to run in order to fetch the file you need to analyze, process it to check for the updated file, and then use the curl command again to download the updated file.

If you don't want to use AppleScript, Automator is another option.

Option 2:

Using Applescript, you could have it trigger another script written in perl, php, or the language of your liking, which could be written to do the same fetching, analysis, and fetching of the updated file. This will provide you the flexibility to write in whatever language you choose based on your comfort level with that language.

An example of writing an AppleScript to trigger another file could be:

do shell script "php ~/Library/Scripts/MyCustomScript.php"

For either option, if you write an AppleScript you can use a program like FastScripts (Also available in the Mac App Store), which adds an icon to the menu bar through which you can easily access your AppleScripts to execute them, but it also provides the added benefit of being able to assign keyboard shortcuts to your AppleScript to trigger them even faster.

share|improve this answer

Use wget

Applescript can also do this easily.

I would use the wget command with a bash script and run it using the the osascript -e command.

share|improve this answer
1  
That would work, but are there any ways to do that without any libraries? –  user3055772 Dec 23 '13 at 16:48
    
Not sure, but there are a couple of people on here who may know a way. Also if you found the answer useful, or helpful I generally upvote it ;-) –  Deesbek Dec 23 '13 at 16:53
    
I would, but I don't have enough reputation. I just started today –  user3055772 Dec 23 '13 at 17:11
    
I already upvoted your question, 4 more rep points and you will be able to upvote. If you answer a question or edit somebody elses post and get it approved you will get the required reputation. –  Deesbek Dec 23 '13 at 17:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.