Type Reference Frustration!!

Here is my script…it simply checks for a file and if its there it does one thing if it isn’t it does another…the problem is i keep getting a can’t make path /a/b/c into type reference no matter how i arrange the path with slashes or colons… any suggestions on how to get this to run.

set a to (POSIX path of ("/Applications/TAU/tau-2.15.4/apple/bin/perfexplorer"))
if exists file a then
	tell application "Terminal"
		activate
		do script "perfexplorer"
	end tell
else
	tell application "Terminal"
		activate
		do script "perfexplorer_configure"
	end tell
end if
exit repeat

POSIX path is a command to make a POSIX style (UNIX) path from an applescript file path not vice versa.
For the other direction you’d use:
set a to (POSIX file (“/Applications/TAU/tau-2.15.4/apple/bin/perfexplorer”))

an other problem: I think your shell script will run in your home directory instead in /Applications/TAU/tau-2.15.4/apple/bin/ (I asume they should run there??)
you’ll need either to cd to the correct dir first or to add the full path to your tools if you want to stay in the home dir.

Also, ‘exists’ is an application keyword belonging to the Finder.

set a to (POSIX file ("/Applications/TAU/tau-2.15.4/apple/bin/perfexplorer"))
tell application "Finder" to set fileExists to (a exists)
if (fileExists) then
	tell application "Terminal"
		activate
		do script "perfexplorer"
	end tell
else
	tell application "Terminal"
		activate
		do script "perfexplorer_configure"
	end tell
end if

Or you could try the old, fast trick of trying to coerce the file specification to an alias:

set a to (POSIX file ("/Applications/TAU/tau-2.15.4/apple/bin/perfexplorer"))
try
	a as alias -- This errors if the file doesn't exist. 
	tell application "Terminal"
		activate
		do script "perfexplorer"
	end tell
on error
	tell application "Terminal"
		activate
		do script "perfexplorer_configure"
	end tell
end try

hmmm…i tried all of those scripts in my script editor and all of them still say that they can’t make the path into a type reference
:o this is so frustrating no matter what i do with the path i get that

set a to "/Applications/TAU/tau-2.15.4/apple/bin/perfexplorer"
set b to (POSIX file a)
tell application "Finder"
	set perfexpExists to (exists b)
end tell
if perfexpExists then ...

Are you, by any chance, putting the lines inside a ‘tell’ block to an application? That could confusion when ‘POSIX file’ is used as a prefix.

tell application "System Events"
	set a to "/Applications/TAU/tau-2.15.4/apple/bin/perfexplorer"
	set b to (POSIX file a)
end tell
--> System Events got an error: Can't make POSIX file "/Applications/TAU/tau-2.15.4/apple/bin/perfexplorer" into type reference.

tell application "Finder"
	set a to "/Applications/TAU/tau-2.15.4/apple/bin/perfexplorer"
	set b to (POSIX file a)
end tell
--> Finder got an error: Can't get POSIX file "/Applications/TAU/tau-2.15.4/apple/bin/perfexplorer".

Alternatives that work for me are to phrase ‘POSIX file’ as a coercion rather than as a specifier, or to make it obvious to the application that a ‘POSIX file’ isn’t supposed to be one of its own classes:

tell application "System Events"
	set a to "/Applications/TAU/tau-2.15.4/apple/bin/perfexplorer"
	set b to (a as POSIX file) -- Coercion.
end tell

tell application "System Events"
	set a to "/Applications/TAU/tau-2.15.4/apple/bin/perfexplorer"
	set b to (my POSIX file a) -- AppleScript's POSIX file, not System Events's.
end tell

I’ve got it in my head from somewhere that a coercion is the correct usage for ‘POSIX file’ anyway.