Hello Hans,
I see I misread your email a bit, but I'm sending my reply to you anyway on the
off-chance there is something you can use.
I don't have that particular file that activates the goofy filename on my
machine. The closest I can come is:
/Volumes/MyHD/private/etc/apache2/httpd.conf
/Volumes/MyHD/private/etc/apache2/original/httpd.conf
And these give me no trouble.
Have you been able to make your script work? If so great; if not I have a few
ideas.
--
Best Regards,
Chris
______________________________________________________________________
On Jan 27, 2011, at 09:14, shlepper wrote:
> Under Tiger it worked excellent:
>
> tell application "BBEdit"
> activate
> open {file "MYHD:private:etc:httpd:httpd.conf"} without LF translation
> open {file "MYHD:private:etc:hosts"} with LF translation
> open {file "MYHD:private:etc:httpd:users:vhosts.conf"} with LF
> translation
> open {file "MYHD:usr:local:php5:lib:php.ini"} with LF translation
> end tell
>
> I know for sure, that the pathnames have changed. But under Snow Leopard I
> get the Recording result for opening the httpd.conf-file the following:
> tell application "BBEdit"
> activate
> open {«data fss 140CHARS-AS-MD5-ENCODED-LOOK-ALIKE»} without LF
> translation
> end tell
>
> Is it possible to use therefore a comfortable readable Applescript statement?
______________________________________________________________________
Hello Hans,
I see you're recording BBEdit. Recording frequently does not produce very
clean Applescript.
An example using invisible files ready-to-hand:
################################################################################################
set homeFolderAlias to path to home folder
set bhAlias to alias ((homeFolderAlias as text) & ".bash_history")
set bpAlias to alias ((homeFolderAlias as text) & ".profile")
tell application "BBEdit"
activate
open {bhAlias, bpAlias}
end tell
tell application "BBEdit"
activate
open bpAlias
open bhAlias
end tell
################################################################################################
It is seems generally silly to use the list form to open a single file:
So let us rewrite: open {file "Thor:Users:chris:.profile"}
As: open alias "Thor:Users:chris:.profile"
(Less silly when opening multiple files at once.)
I believe Steve is right when he says the linefeed translation option is
unnecessary. The BBEdit Applescript Dictionary reads: LF translation |
optional | boolean | convert line feeds in open documents? (By Default, the
preference setting.)
As you can see in the script above I have not hard-coded my paths but used a
relative path-specifier for the 'Home Folder' on this system. The variables
will resolve to:
bhAlias == alias "Thor:Users:chris:.bash_history"
bpAlias == alias "Thor:Users:chris:.profile"
Doing things this way makes your scripts more portable between machines or
different system installs on the same machine.
Now. Here's an example specific to your problem:
################################################################################################
set hostsFile to (path to startup disk as text) & "private:etc:hosts"
-- This converts the path string to an alias and will throw an error if the
file does not exist.
try
set hostsFile to alias hostsFile
on error errMsg number errNum
beep
tell me to display dialog "Error: " & errMsg & return & "Error Number: " &
errNum
return
end try
tell application "BBEdit"
try
-- activate
open hostsFile
on error errMsg number errNum
set sep to "=============================="
set e to sep & return & errMsg & return & sep & return ¬
& "Error Number: " & errNum & return & sep
beep
tell me to display dialog e
end try
end tell
################################################################################################
* John is absolutely right when he suggests testing for the existence of the
file before trying to open it. It's good practice.
--
Chris
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>