LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-16-2014, 07:27 PM   #1
nbritton
Member
 
Registered: Jun 2013
Location: Dubuque, IA
Distribution: Red Hat Enterprise Linux, Mac OS X, Ubuntu, Fedora, FreeBSD
Posts: 89

Rep: Reputation: Disabled
Variables in AppleScript


I want to do a repeat loop in AppleScript, but I'm not getting how to reference variables in this language. Here is the AppleScript I want, my problem is I don't know how to output the value of the variable, I've use $myVariable as an example:

Code:
repeat with myVariable from 1 to 30000
	tell application "Safari"
		activate
		set URL of document 1 to "https://www.example.com/$myVariable"
		delay 2
		set myString to source of document 1
	end tell
	set newFile to POSIX file "/Users/nbritto/project/$myVariable"
	open for access newFile with write permission
	write myString to newFile
	close access newFile
end repeat
 
Old 11-16-2014, 08:00 PM   #2
nbritton
Member
 
Registered: Jun 2013
Location: Dubuque, IA
Distribution: Red Hat Enterprise Linux, Mac OS X, Ubuntu, Fedora, FreeBSD
Posts: 89

Original Poster
Rep: Reputation: Disabled
I figured it out.

Code:
repeat with myVariable from 1 to 30000
	tell application "Safari"
		set URL of document 2 to "https://www.example.com/" & myVariable
		delay 2
		set myString to source of document 2
	end tell
	set myFile to "/Users/nbritto/project/" & myVariable
	set newFile to POSIX file myFile
	open for access newFile with write permission
	write myString to newFile
	close access newFile
end repeat

Last edited by nbritton; 11-16-2014 at 08:21 PM.
 
Old 11-16-2014, 08:23 PM   #3
nbritton
Member
 
Registered: Jun 2013
Location: Dubuque, IA
Distribution: Red Hat Enterprise Linux, Mac OS X, Ubuntu, Fedora, FreeBSD
Posts: 89

Original Poster
Rep: Reputation: Disabled
The reason I needed to use Safari/AppleScript was because the site uses some type of authentication system, does any know how to do this with wget? I exported my cookies and tried "wget --load-cookies=cookies.txt" but that didn't work.

Last edited by nbritton; 11-16-2014 at 08:28 PM.
 
Old 11-16-2014, 09:01 PM   #4
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Quote:
Originally Posted by nbritton View Post
the site uses some type of authentication system, does any know how to do this with wget?
Depends on the type of authentication system.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cronjob that launches applescript app once a day please help taffners *BSD 4 05-19-2012 01:43 PM
cronjob that launches applescript app once a day please help taffners Linux - Newbie 3 05-10-2012 01:49 PM
Run remote AppleScript from linux scotlarsen Linux - Server 1 02-02-2008 02:40 PM
AppleScript-like stuff for Linux vvkozmenko Linux - General 4 09-03-2006 03:06 AM
Applescript witeshark Programming 2 02-12-2004 09:52 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration