mount remote volume + mount local volume on remote machine

I’m working on a network synching script that requires that the home directory of the local machine is mounted as a volume on the remote machine, and vice versa, ie that the the home directory on the remote machine is mounted as a volume on the local machine.

The script is in pretty good shape (or can be made to work) assuming that this is the case, BUT, how would you accomplish this in applescript? I assume it would involve some “do shell script” commands, but which ones? The furthermore, how about (the probably more difficult issue of) mounting the local volume on the remote machine? can you execute shell commands on the remote machine using the ‘tell application “terminal” of machine remotemachine’ construct?

Thanks.

well I more or less figured this out, in case it’s of any use to anyone… some portions based on other afp mounting scripts found here.

Obviously, remote events has to be on in sharing on both machines.

property remotemachineip : "192.168.1.107"  -- example, this would be for a LAN address 
property localmachineip : "192.168.1.202"  --- example, a LAN address

property remotehome : "remotevolumename"  -- the name of the remote volume you want to mount on the local system
property localhome : "localvolumename"  --- the name of the local volume you want to mount on the remote system

property ret : return & return
property remotemounted : false
property localmounted : false

global localmachine, remotemachine

set remotemachine to ("eppc://" & remotemachineip) as string
set localmachine to ("eppc://" & localmachineip) as string

set remotemounted to mountremote() of me
if not remotemounted then
	---do something
end if
set result to remotemounted


set localmounted to mountlocal() of me
if not localmounted then
	---do something
end if
set result to localmounted


on checkremote()
	tell application "Finder" to set thedisknames to name of every disk
	if thedisknames contains remotehome then
		return true
	else
		return false
	end if
end checkremote

on mountremote()
	set remotemounted to checkremote() of me
	if not remotemounted then
		set ping_result to (do shell script "ping -c 1 " & remotemachineip)
		if "100% packet loss" is in ping_result then
			return false
		else if "0% packet loss" is in ping_result then
			set thepassword to text returned of (display dialog remotehome & "@" & remotemachineip & ret & "Passwords may be sent insecurely." with title "Enter Password for Remote Computer" default answer "" with hidden answer)
			try
				with timeout of 20 seconds
					mount volume ("afp://" & remotehome & ":" & thepassword & "@" & remotemachineip & "/" & remotehome) as string
				end timeout
			on error
				return false
			end try
			set remotemounted to checkremote() of me
			if remotemounted then
				return true
			else
				return false
			end if
		else
			return false
		end if
	else
		return true
	end if
end mountremote

on checklocal()
	using terms from application "Finder"
		tell application "Finder" of machine remotemachine to set thedisknames to name of every disk
	end using terms from
	if thedisknames contains localhome then
		return true
	else
		return false
	end if
end checklocal

on mountlocal()
	set localmounted to checklocal() of me
	if not localmounted then
		---set ping_result to (do shell script "ping -c 1 " & remotemachineip)
		--- do not know how to execute terminal command on remote machine, so we assume the local afp server is on
		set ping_result to "0% packet loss"
		if "100% packet loss" is in ping_result then
			return false
		else if "0% packet loss" is in ping_result then
			set thepassword to text returned of (display dialog localhome & "@" & localmachineip & ret & "Passwords may be sent insecurely." with title "Enter Password for Local Computer" default answer "" with hidden answer)
			try
				with timeout of 20 seconds
					using terms from application "Finder"
						tell application "Finder" of machine remotemachine
							mount volume ("afp://" & localhome & ":" & thepassword & "@" & localmachineip & "/" & localhome) as string
						end tell
					end using terms from
				end timeout
			on error
				return false
			end try
			set localmounted to checklocal() of me
			if localmounted then
				return true
			else
				return false
			end if
		else
			return false
		end if
	else
		return true
	end if
end mountlocal