Remote POSIX path as variable

Does anybody have a clue why using a variable as the remote path with Remote Apple Events doesn’t work in some circumstances, as shown next.

If I format the remote path in the variable as a POSIX path, commands like ‘entire contents’ or ‘delete’ do not interpret the path correctly, on the other hand, ‘make new folder’ does interpret it correct. If I type the path directly (as in, without the use of a variable) it all works perfectly. If I use HFS paths (‘:’ delimited) it all works OK, but in my application I prefer to use POSIX style paths.
I have tried to force the variable ‘as text’ or ‘as alias’, to no avail. Setting it in the tell remote Finder block has no effect either.

A POSIX path without the use of a variable, works as expected:

set remoteMac to "eppc://name:pass@server.domain.com"

tell application "Finder" of machine remoteMac
	using terms from application "Finder"
		set showDir to entire contents of folder POSIX file "/Volumes/RAID/ServiceData/bin/remoteApp.app/Contents/Resources/Folders/"
	end using terms from
end tell

While this doesn’t work:

set remoteMac to "eppc://name:pass@server.domain.com"
set remotePath to "/Volumes/RAID/ServiceData/bin/remoteApp.app/Contents/Resources/Folders/"

tell application "Finder" of machine remoteMac
	using terms from application "Finder"
		set showDir to entire contents of folder POSIX file remotePath
	end using terms from
end tell

It throws the error:

A weird thing to me is that ‘make new dir’ does work, while I would expect it to throw a similar error:

set remoteMac to "eppc://name:pass@server.domain.com"
set remotePath to "/Volumes/RAID/ServiceData/bin/remoteApp.app/Contents/Resources/Folders/"

tell application "Finder" of machine remoteMac
	using terms from application "Finder"
		set newDir to make new folder at POSIX file remotePath with properties {name:"The new directory"}
	end using terms from
end tell

An HFS-styled path seems to work in all circumstances:

set remoteMac to "eppc://name:pass@server.domain.com"
set remoteHfsPath to "RAID:ServiceData:bin:remoteApp.app:Contents:Resources:Folders:"

tell application "Finder" of machine remoteMac
	using terms from application "Finder"
		set showDir to entire contents of folder remoteHfsPath
	end using terms from
end tell

Any thoughts, anybody?

thanks,
Cliff

Hi,

it’s always recommended to use the native file system path specifier of a programming language
which is HFS in case of AppleScript.

Too many coercions consume too much execution time.

The main problem of the POSIX file coercion is that the result is a file URL, which must be coerced to text or alias for proceeding with the Finder.

Avoid also any code in a remote block which could be executed outside


set remoteMac to "eppc://name:pass@server.domain.com"
set remotePath to "/Volumes/RAID/ServiceData/bin/remoteApp.app/Contents/Resources/Folders/"
set remoteHFSPath to POSIX file remotePath as text --> "RAID:ServiceData:bin:remoteApp.app:Contents:Resources:Folders:"
tell application "Finder" of machine remoteMac
	using terms from application "Finder"
		set showDir to entire contents of folder remoteHFSPath
	end using terms from
end tell


Hi Stefan,

Thanks for your advice.

This still results in a coercing towards the local drive, in stead of my severs RAID volume.

I need the POSIX path in some bash scripts further on in the application. It looks like I can get around by maintaining two separate string variables, one for the HFS path, the other for the POSIX one, to avoid local coercing of the remote POSIX path.

thanks,
Cliff

The (coercion) error occurs, if the specified volume is not available