Automatic ARA Connection Script
Automatic ARA Connection Script
- Subject: Automatic ARA Connection Script
- From: Tod Hallberg <email@hidden>
- Date: Tue, 16 Jan 2001 09:14:29 -0600
- Organization: Monical Pizza Corporation
I wrote this script to automate copying of specific files from a large
number of different locations.
It works ok on an imac 350, 8.6, 1.3.7....however when I transfer it to
a Beige G3 266, 8.6, 1.3.7, I get cant find script errors when I try to
open it in script editor, unless it is on the desktop. Also, it always
asks where Remote Access is. Even if I find it then save as an
application, it asks every time the script is run.
any help would be great....especially ways of refining the code.
thanx
tod
P.S.
it uses 4 simple text docs in the system folder (Passwords, Store Name,
Local Passwords, Store Phone Numbers)
The documents are space separated words.
set araDialInName to "MyName"
set masterTerminalUserName to "OurName"
set targetDataDisk to "DataDisk"
set targetComputer to "Computer"
set targetFileFolder to "TargetFolder"
set todaysDate to current date
set dataDate to todaysDate - (6 * days)
set mySysFolder to path to system folder
set allPasswords to ""
set allStoreNames to ""
set allStoreMasterTerminalUserPassword to ""
set allStoreModemNumber to ""
--Read Password File
tell application "Finder"
read file "Passwords" of system folder
set allPasswords to the result
read file "Store Name" of system folder
set allStoreNames to the result
read file "Local Passwords" of system folder
set allStoreMasterTerminalUserPassword to the result
read file "Store Phone Numbers" of system folder
set allStoreModemNumber to the result
try
get name of every process as string
set allProcesses to result
if allProcesses contains "Remote Access" then
tell application "Remote Access"
quit
end tell
end if
on error
end try
end tell
set storeNumber to ""
set storePassword to ""
set storeName to ""
set masterTerminalUserPassword to ""
set storeModemNumber to ""
display dialog "What store would you like to call? (2-37)" default
answer ""
set storeNumber to text returned of the result
set storePassword to word storeNumber of allPasswords
set storeName to word storeNumber of allStoreNames as string
set masterTerminalUserPassword to word storeNumber of
allStoreMasterTerminalUserPassword
set storeModemNumber to word storeNumber of allStoreModemNumber
--Begin Part 1
--Change Appletalk from current config to a new "Remote Only" config
set origActiveAppleTalkConfigSet to ""
tell application "Network Setup Scripting"
launch
try
open database
on error
end try
--get active Appletalk config set
set origActiveAppleTalkConfigSet to the (name of every AppleTalk
configuration whose active is true)
set origActiveAppleTalkConfigSet to origActiveAppleTalkConfigSet as
text
try
begin transaction
on error
end try
if AppleTalk configuration "Remote Only" exists then
if active of AppleTalk configuration "Remote Only" * true then
set active of AppleTalk configuration "Remote Only" to true
end if
try
set connecting via of AppleTalk configuration "Remote Only" to
"Remote Only"
on error
end try
else
make new AppleTalk configuration "Remote Only" with properties ,
{active:true, connecting via:"Remote Only"}
end if
try
end transaction
on error
end try
---------------------------------------------------------------------------------
try
begin transaction
on error
end try
if Remote Access configuration storeName exists then
if active of Remote Access configuration storeName * true then
set active of Remote Access configuration storeName to true
end if
else
make new Remote Access configuration storeName with properties ,
{protocol:ARAP, active:true, user name:araDialInName, phone
number:storeModemNumber, saves password:false}
end if
try
end transaction
on error
end try
try
close database
on error
end try
end tell
--End Part 1
beep 1
--Begin Part 2
try
tell application "Remote Access"
activate
end tell
on error
end try
try
repeat
try
RA connect password storePassword
on error
tell me to activate
display dialog "Sorry, connection cannot be made. Please check all
connections and try again." buttons {"Ok", "Cancel"} default button
{"Cancel"}
exit repeat
end try
delay 2
try
if state of (RA status) * "connected" then
delay 5
else
exit repeat
end if
on error
tell me to activate
display dialog "Sorry, connection cannot be made. Please check all
connections and try again."
exit repeat
end try
end repeat
--end part 2
beep 2
--begin part 3
--mount "pos data folder" of "master terminal" of selected store
repeat until state of (RA status) = "connected"
with timeout of 10 seconds
delay 1
end timeout
end repeat
mount volume targetDataDisk on server targetComputer as user name
masterTerminalUserName with password masterTerminalUserPassword
set allDiskList to list disks
if allDiskList contains targetDataDisk then
beep 3
--Part 4
tell application "Finder"
with timeout of 600 seconds
activate
set targetFileFolderInfo to (info for "POS Data Folder:Office
Packages")
set targetFileFolderDate to modification date of
targetFileFolderInfo
if targetFileFolderDate * dataDate then
if folder storeName exists then
try
delete (every item of folder storeName)
on error
end try
duplicate (every item of folder targetFileFolder of disk
targetDataDisk) to folder storeName
else
make new folder with properties {name:storeName, has custom view
settings:true, view:list, uses relative dates:false}
duplicate (every item of folder targetFileFolder of disk
targetDataDisk) to folder storeName
end if
else
display dialog "Office Packages don't have the correct date.
Please do an export and try again."
end if
end timeout
end tell
end if
beep 4
on error
end try
--Start Part 6
--Unmount POS data folder and disconnect
tell application "Finder"
set expelList to list disks
if expelList contains targetDataDisk then
expel targetDataDisk
end if
end tell
try
RA disconnect
on error
end try
--Begin Part 7
--Reset AppleTalk & Remote Access to original setting
try
tell application "Finder"
get name of every process as string
set allProcesses to result
if allProcesses contains "Remote Access" then
tell application "Remote Access"
quit
end tell
end if
end tell
on error
end try
tell application "Network Setup Scripting"
try
open database
on error
end try
try
begin transaction
on error
end try
if origActiveAppleTalkConfigSet * "Remote Only" then
set active of AppleTalk configuration "Remote Only" to false
set active of AppleTalk configuration the origActiveAppleTalkConfigSet
to true
end if
try
end transaction
on error
end try
try
close database
on error
end try
end tell