how to start an iDisk synchronize

Helllo,

I have written/cobbled together the following script that uses mail and WireTap Pro to start a recording using commands sent via email. Once the recording is complete it is placed into the iDisk/public folder and then uploaded to my .mac account where the file can be downloaded. It is mostly working the way that I want however I still have some clean up to do.

My current problem: When the recording completes successfully and the file is placed in the iDisk/public folder (this is done automatically by WireTap Pro), even though I have iDisk syncing set to automatic it never seems to start the upload of the file. I have not been able to find a way to start the sync using AS or maybe there is a better way to upload the file.

Any help or suggestions appreciated!
Craig

--
-- CommandRecord version .9 
--    8/27/2007
--
--Known issues 8/27/07--
-- start the iDisk sync process upon completion
--recorded file name is sometimes reported as the prior file
--format the file size
--format the time recorded
--format the name of the file
-- rename the output file acording the the requesting email address and time
-- error handling if recording is already in progress
--
--
--Assumptions
-- script assumes that wiretap is set up with the default recording settings 
--  to name the file and drop it in the public idisk folder
-- script is called when email contains "Record, start or stop"

--get variables from the requesting email
using terms from application "Mail"
	on perform mail action with messages these_messages for rule this_rule
		-- PROCESS THE MESSAGES PASSED TO THIS HANDLER
		tell application "Mail"
			repeat with i from 1 to the count of these_messages
				set this_message to item i of these_messages
				tell this_message
					set this_subject to its subject
					set the reply_address to its reply to
					set this_sender to its sender
					set this_content to its content
				end tell
				
				--get current status of WTP and quit if recording
				tell application "WireTap Pro"
					set the_status to the current state
				end tell
				
				if the_status = "Recording" then
					beep
					--send a message that WTP is already recording
					set reply_subject to "Error, recording already in progress"
					set reply_content to "Please try again later."
					set the outgoing_message to make new outgoing message with properties {subject:reply_subject}
					tell outgoing_message
						make new to recipient with properties {address:this_sender}
						set content to reply_content
					end tell
					send outgoing_message
					quit
				end if
				
				
				-- what type of request is this
				-- options are "start", "stop" and "Record"
				-- Record is an option to record for a specified time
				if this_subject begins with "stop" then
					tell application "WireTap Pro"
						set the_amountRecorded to the (amount recorded) & " bytes"
						set the_time to the (time recorded / 60) & " minutes"
						stop recording
						set the_savedPath to the saved path
						
					end tell
					set reply_subject to "Recording stopped: " & (current date)
					set reply_content to "The recording will be posted to the server shortly. The file size is: " & the_amountRecorded & return & "The duration of recording is: " & the_time & return & "The file name is: " & the_savedPath
					
					--Start a recording	
				else if this_subject begins with "start" then
					tell application "WireTap Pro"
						start recording
					end tell
					set reply_subject to "Recording started: " & (current date)
					set reply_content to this_sender & " started a recording at the above time. Do not forget to send the 'Stop' command. Thank you."
					
					--Timed recording	
				else if this_subject begins with "record" then
					--start_spec_local is the time to start recording, always assumed to be now
					set start_spec_local to current date
					
					tell application "WireTap Pro"
						start recording
					end tell
					
					-- subtract out the "Record " = 7 characters + 1 for space
					-- the remainder is the time to record in minutes
					set the_recTime to characters 8 thru -1 of this_subject
					-- get this value from email subject "mm"
					set recording_minutes to the_recTime
					
					-- if recording minutes is less than 10 minutes we need to add a leading 0
					set recmincnt to count recording_minutes
					if recmincnt = 1 then
						set recording_minutes to "0" & recording_minutes
					end if
					
					--convert to standard time
					set recording_length to "00:" & recording_minutes & ":00"
					
					--send a message that recording has started
					set reply_subject to "Timed recording started at: " & (current date) & " for " & the_recTime & " minutes. "
					set reply_content to this_sender & " started a timed recording. You will receive another email when the recording is complete. "
					set the outgoing_message to make new outgoing message with properties {subject:reply_subject}
					tell outgoing_message
						make new to recipient with properties {address:this_sender}
						set content to reply_content
					end tell
					send outgoing_message
					
					set ctts_time to recording_length
					--
					-- Convert time string (nn:nn:nn) to seconds
					--
					set ctts_saved_delimiters to AppleScript's text item delimiters
					set AppleScript's text item delimiters to {":"}
					set ctts_seconds to 0
					set ctts_no_words to number of words of ctts_time
					if ctts_no_words ≥ 1 then
						set ctts_seconds to ctts_seconds + (first word of ctts_time) * hours
						if ctts_no_words ≥ 2 then
							set ctts_seconds to ctts_seconds + (second word of ctts_time) * minutes
							if ctts_no_words ≥ 3 then
								set ctts_seconds to ctts_seconds + (third word of ctts_time)
							end if
						end if
					end if
					set AppleScript's text item delimiters to ctts_saved_delimiters
					set stop_time_delay to ctts_seconds
					
					
					
					-- Wait until the stop time to stop recording
					if stop_time_delay is greater than 0 then
						
						set dws_end_time to start_spec_local + stop_time_delay
						set dws_message to "Recording for " & recording_length & " (hh:mm:ss)"
						
						-- Delay until the time to do something, displaying a dialog containing a status message.
						-- This relies on the "giving up after" functionality of the display dialog command.
						-- If the OK button is clicked, the display dialog is redone with an adjusted delay time.
						--
						-- dws_end_time is the time the delay is to end
						-- dws_message is the message to display in the dialog
						
						-- Seconds to delay
						local dws_end_time_delay
						set dws_end_time_delay to (dws_end_time - (current date))
						repeat while dws_end_time_delay > 0
							activate me
							display dialog dws_message buttons {"Cancel"} giving up after dws_end_time_delay
							if button returned of the result is "Cancel" then error
							set dws_end_time_delay to (dws_end_time - (current date))
						end repeat
						
					end if
					
					tell application "WireTap Pro"
						set the_amountRecorded to the (amount recorded) & " bytes"
						set the_time to the (time recorded / 60) & " minutes"
						stop recording
						set the_savedPath to the saved path
					end tell
					--build completion email 
					set reply_subject to "Timed recording stopped: " & (current date)
					set reply_content to "The recording will be posted to the server shortly. The file size is: " & the_amountRecorded & return & "The duration of recording is: " & the_time & return & "The file name is: " & the_savedPath
				end if
				
				-- create outbound message
				set the outgoing_message to make new outgoing message with properties {subject:reply_subject}
				tell outgoing_message
					make new to recipient with properties {address:this_sender}
					set content to reply_content
				end tell
				send outgoing_message
			end repeat
		end tell
	end perform mail action with messages
end using terms from


on delay_with_status(dws_end_time, dws_message)
	--
	-- Delay until the time to do something, displaying a dialog containing a status message.
	-- This relies on the "giving up after" functionality of the display dialog command.
	-- If the OK button is clicked, the display dialog is redone with an adjusted delay time.
	--
	-- dws_end_time is the time the delay is to end
	-- dws_message is the message to display in the dialog
	
	-- Seconds to delay
	local dws_end_time_delay
	set dws_end_time_delay to (dws_end_time - (current date))
	repeat while dws_end_time_delay > 0
		activate me
		display dialog dws_message buttons {"Cancel"} giving up after dws_end_time_delay
		if button returned of the result is "Cancel" then error
		set dws_end_time_delay to (dws_end_time - (current date))
	end repeat
	
end delay_with_status

Hi Craig,

what’s about mounting the iDisk and save the file(s) directly

this is a subroutine to mount the iDisk. It returns either the name of the volume or boolean false

property pass : "¢¢¢¢¢¢"

set iDisk to MountiDisk()
if iDisk is false then
 -- do some error handling
end if

on MountiDisk()
	set iDiskName to do shell script "defaults read .GlobalPreferences iToolsMember"
	try
		mount volume ("http://idisk.mac.com/" & iDiskName) as user name iDiskName with password pass
	on error e number n
		if n is not in {-55, -128} then return false
	end try
	return iDiskName
end MountiDisk 

That’s interesting about how you can control things through email from a remote location. Have you thought to use Appple Remote Desktop to control your computer remotely? It might be easier to actually see what’s going on rather then sending email commands and waiting for replys.

Good question. I do have apple remote desktop to control the recording system remote when I am at home. However, the application is used to record a specific frequency on amateur radio (Ham) so at the house I have a radio connected to a headless mac mini that is connected to the internet with an email account. At times a recording may need to be triggered from out in the field where a computer is not available, but a cell phone would almost always be available. So this setup allows some additional freedom and flexibility. I have found in testing that an email sent to the system will almost always be received and acted upon in under an minute and generally less than 30 seconds. This timing works for me!

This is a good ideal and one that I had initially considered however I thought I would leave as much work to the OS as possible. Now that I am having problems I will go back and give this a try. It is probably better to do it this way anyway. Thanks for the quick reply! Craig

OK, that makes sense. Good luck.