0

I am trying to add a script to BBEdit 10 that will validate PHP files. I have enabled PHP & Web Sharing on my Mac and I think the script is accurate but I am having an issue which I think is being caused by a volume name having a space.

property phpref : "/usr/bin/php -l "
try
    tell application "BBEdit" to get file of first text window
    do shell script phpref & POSIX path of result
    display dialog "Ok: " & result buttons {"Finished Checking"} default button 1
on error msg
    display dialog "Err: " & msg buttons {"Finished Checking"} default button 1
end try

I am getting an error with get file of. The error is: Could not open input file: /Volumes/ Data

The volume name is "Data HD" which is why I think the space is causing the issue. Can I escape a space when calling get file of?

2 Answers 2

2

The question was answered at another site. I wanted to share the final answer. The issue was not with getting the file. It was with the command line using the file path.

This is the correct and working scripr:

property phpref : "/usr/bin/php -l "
try
    tell application "BBEdit" to get file of first text window
    do shell script phpref & quoted form of POSIX path of result
    display dialog "Ok: " & result buttons {"Finished Checking"} default button 1
on error msg
    display dialog "Err: " & msg buttons {"Finished Checking"} default button 1
end try
1
  • By setting xxx to quoted form of POSIX path ... you are preparing the command line command. Your solution and mine produce the same result.
    – adayzdone
    May 12, 2012 at 13:08
0

I can't test it but try:

tell application "BBEdit" to set xxx to quoted form of POSIX path of (get file of first text window)
do shell script phpref & xxx

In Finder, it would look something like this:

tell application "Finder" to set xxx to quoted form of POSIX path of (get file 1 of desktop as alias)

Have you tried temporarily renaming the volume without a space to verify that it is the cause of the problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.