Error 10810 when running applescript remotely
So "final" product here. I'm no applescripter so my code is probably inefficient. As such I keep running into a -10810 error and from my googling and research I think it's a runaway process (or a few of them) created by this script. I run it through Casper remote. It's a compiled script for compatibility with Casper Remote. Running as a standalone app (or as a compiled script on the local desktop) it works just fine. It's only through Casper Remote that I get this error and only sometimes. The script works even when no one is logged in. Casper Remote runs as an admin and forces sudo when it needs to.
Any ideas as to what might be causing the failure? The script fails very quickly when it does. It certainly does not get to the point where it gathers all apps on the computer.
TIA!
Andrew
(*This script should be run first on a computer to be upgraded.
It collects the size of the users's homefolder and any folders
common to all users (Workfolder, PAGEFOLDER, etc). Common units get
all users transfered. It also collects apps installed in /Applications. It is to
be run again on the new computer to verify that all data and apps were
copied over correctly. It outputs the data to a log at
/netappv2/MacPackaging/FY12MacDAC-UserMigration titled with the
User's username, old mac name *)
on run argv
------------------------------
-- Define static variables --
------------------------------
---- "\n"
-- Capture the user's name (passed from Casper Remote)
set userName to item 4 of argv
-- if a username was not passed to the script, quit immediately
if userName = "" then
do shell script "echo No username specified! Try again with a valid username"
error number -128
else if userName is in {"Common", "common", "COMMON"} then
do shell script "echo **********THIS IS A COMMON UNIT. ALL USERS WILL BE TRANSFERED! **********"
end if
-- Capture computer name and current date
set computerName to computer name of (system info)
set currentDate to current date
-------------------------
-- Define file access --
-------------------------
-- We first have to create a file so we can reference it via Applescript for writing. We do this via the shell
set shellLogFile to computerName & "-" & userName & ".txt"
do shell script ("mkfile 10k /private/var/root/Desktop/" & shellLogFile)
-- Make a directory on the server particular to this user and computer since two reports will be made: one for the old computer and one for the new
set logFolder to computerName & "-" & userName
do shell script "mkdir -p -m 777 /Volumes/MacPackaging/FY12MacDAC-UserMigration/" & logFolder
-- Open a text file for writing the DAC data collection information. Alias it to the file we just created
-- the file is located on roots desktop, but it is aliased to the current user's desktop (if one is logged in)
set logFile to (((path to desktop) as string) & computerName & "-" & userName & ".txt") as alias
open for accesslogFile with write permission
set eof of logFileto 0
---------------------------
-- Write log headers --
---------------------------
-- Write relevant user and computer information to the log file
if userName is equal to "common" then
write "**********THIS IS A COMMON UNIT. ALL USERS WILL BE TRANSFERED! **********
" tologFile
write "
" tologFile
end if
write "Report run date: " & currentDate & "
" tologFile
write "User to be migrated: " & userName & "
" tologFile
write "Computer to be migrated: " & computerName & "
" tologFile
write "=========================" & "
" tologFile
write "
" tologFile
----------------------------------------
-- Begin data collection output --
----------------------------------------
-- First check for the existence of partition "work"
write "Folders on Work partition to be transfered" & "
" tologFile
write "========================================" & "
" tologFile
set workPath to "Work" --we are only looking for partition "Work"
tell application "System Events"
if workPath is in (get the name of every disk) then -- list all partitions and check for "Work." If found, set folderList to the contents of Work
set folderList to list folder workPath without invisibles
else
set workPath to (get the name of every disk) -- if "Work" is not found, list the mounted partitions and exit
write "No Work partition! Available partitions are: " & workPath & ". Exiting." & "
" tologFile
do shell script "echo No Work partition!"
do shell script "echo Available partitions are: " & workPath
close accesslogFile
error -128
end if
end tell
-- Next write the root level contents of the Work partition and their sizes. These main folders and their entire contents (except Users) will be transferred. For user folders, only the /Users/username and Users/Shared folder will be transferred
set totalSize to 0 --set a count for the size of each folder found. This will be the total size of all data to be migrated
repeat with aFolder in folderList
if aFolder contains "Users" then
set userFolder to "/" & aFolder & "/" & userName-- rename the folder to the explicit path to the users home folder (name provided when the script was run), since we aren't interested in any other user folder
set sharedFolder to "/" & aFolder & "/Shared" -- create another variable to hold the Shared folder since we need to copy this as well
---------------------------------------------
set UNIXFolder to quoted form of POSIX path of userFolder
set folderSize to (do shell script "du -k /Volumes/Work" & UNIXFolder & " | tail -rn1 | awk '{print \"\" $1}'") as integer -- extract the size of the users home folder
set totalSize to totalSize + folderSize
writeuserName & " home folder - " & CalcFolderSize(folderSize) & " " & KBMBGB(folderSize) & "
" tologFile
set UNIXFolder to quoted form of POSIX path of sharedFolder
set folderSize to (do shell script "du -k /Volumes/Work" & UNIXFolder & " | tail -rn1 | awk '{print \"\" $1}'") as integer -- extract the size of the Users/Shared folder using the same method as above
set totalSize to totalSize + folderSize
write "Users/Shared - " & CalcFolderSize(folderSize) & " " & KBMBGB(folderSize) & "
" tologFile
else if aFolder does not contain "Users" then
set UNIXFolder to quoted form of POSIX path of aFolder
set folderSize to (do shell script "du -k /Volumes/Work" & UNIXFolder & " | tail -rn1 | awk '{print \"\" $1}'") as integer -- extract the size of aFolder if other than "Users"
set totalSize to totalSize + folderSize
writeaFolder & " - " & CalcFolderSize(folderSize) & " " & KBMBGB(folderSize) & "
" tologFile
end if
end repeat
write "____________________" & "
" tologFile
write "Total copy size: " & CalcFolderSize(totalSize) & " " & KBMBGB(totalSize) & "
" tologFile
write "
" tologFile
-- Record all departmental apps that need to be installed on the new mac
write "Departmental apps to install on the new mac" & "
" tologFile
write "===========================================" & "
" tologFile
-- A pre-defined list of departmental apps. These apps are not included in the AG Core image and need to be installed on the new mac. All relevant transferrable apps are in the Applications and Utilities folders. Apps installed elsewhere are not AG standard and do not get transferred
set theApps to {"Adobe Acrobat 7.0 Professional.app", "Adobe After Effects CS4.app", "Adobe After Effects CS3.app", "Adobe Fireworks CS3.app", "Adobe Flash CS4.app", "Adobe Flash CS3.app", "ColorEyes Display Pro.app", "ColorThink 2.2.1b2", "Corel Painter X.app", "DiskTracker 2.3.2", "DiskTracker.app", "Dreamweaver.app", "EPSON Scan.app", "Fetch.app", "formZ RenderZone Plus.app", "Google Earth Pro.app", "Google Earth.app", "iMovie.app", "Keyspan Serial Assistant.app", "Flash 8.app", "Microsoft Excel.app", "Microsoft Excel", "Microsoft Word.app", "Microsoft Word", "Microsoft PowerPoint.app", "Microsoft PowerPoint", "PhotoZoom Pro 2.app", "Product Ingest.app", "Product Tag.app", "Art Ingest.app", "ProfileMaker", "TextWrangler.app", "Toast Titanium.app", "ToolCrib.app", "Winclone.app", "Suitcase Fusion 2.app", "Suitcase Fusion 3.app", "BRASS.app", "Final Cut Pro.app", "Pro Tools LE.app", "LightWave", "VMware Fusion.app"}
set appsPath to (path toapplications folder)
tell application "Finder"
set appList to name of every application file of entire contents of folder appsPath
end tell
repeat with anApp in theApps
if appList contains anApp then
set anAppID to id of (application anApp)
if anAppID is not equal to "????" then
tell application "Finder" to tell (application file id anAppID)
set vers to version of application fileidanAppID
set parentFolder to name of its container
end tell
if parentFolder is in {"Applications", "Utilities"} then
set parentFolder to ""
end if
write anApp & "
" & "Version: " & vers & "
" & parentFolder & "
" tologFile
write "--------------------------------------" & "
" tologFile
write "
" tologFile
else if anAppID is equal to "????" then
write anApp & "
" tologFile
write "--------------------------------------" & "
" tologFile
write "
" tologFile
end if
end if
end repeat
write "
" tologFile
-- Collect all the printers that need to be installed on the new Mac
write "Printers to install on the new mac" & "
" tologFile
write "===================================" & "
" tologFile
(*tell application "Printer Setup Utility"
set printerList to the name of every printer as list
end tell
repeat with aPrinter in printerList
write aPrinter & "
" to logFile
end repeat*)
set printerList to do shell script "lpstat -a | awk '{print $1}'" as text
writeprinterList & "
" tologFile
close accesslogFile
-- edit file permissions so everyone can read it
do shell script "chmod 755 /private/var/root/Desktop/" & shellLogFile
-- copy the file to macpackaging for later use
do shell script "ditto /private/var/root/Desktop/" & shellLogFile & " /Volumes/Macpackaging/FY12MacDAC-UserMigration/" & logFolder
end run
-- subroutine for converting folderSize
on CalcFolderSize(KBParam)
if KBParam ≥ 1048576 then -- convert to GB
return (KBParam / 1024 / 1024)
else if KBParam ≥ 1024 then -- convert to MB
return (KBParam / 1024)
else
return (KBParam)
end if
end CalcFolderSize
-- subroutine for determing KB, MB, or GB
on KBMBGB(paramSize)
if paramSize ≥ 1048576 then -- 1GB
return ("GB")
else if paramSize ≥ 1024 then -- 1MB
return ("MB")
else
return ("KB")
end if
end KBMBGB
MacPro 2x2.66GHz Dual Core Xeon, 4GB RAM,, Mac OS X (10.6.4)