Hi,
I am new to apple script. I am using the following script file as a resource while creating an application pkg. This is working fine on Jaguar and panther. The script is failing on Tiger. Any kind of help in this regard is highly appreciated.
if the button returned of the result is "Server" then
display dialog "Enter either a server ." default answer the "<port number>@<server name>" buttons {"OK", "Cancel"} default button 1
if the button returned of the result is "OK" then
set license_server to the text returned of the result
tell application "Finder" to set license_server_file to (make new file at "tmp" with properties {name:"license.srv"})
try
set license_server_file to license_server_file as text
set the open_target_file to open for access file license_server_file with write permission
write license_server to the open_target_file starting at eof
close access file open_target_file
on error
display dialog errorMessage
try
close access file license_server_file
close access file open_target_file
end try
end try
end if
end if
Thanks,
-Rao
Moving this to the OS X forum.
Also changed your post because it didn’t follow the guidelines for posting code.
ok - I know this is applescript your asking about - but what I do whenever I’m trying to write/create log files is
a do shell script
Allow me to explain.
theis line would: write append to the contents of license_server_file to a file named license.srv in the tmp directory IF the file was already there…or it would create the file if it didn’t already exist. Far easier to do it this way in one line rather than the 10 or so that are required to do it with AppleScript IMO…
set license_server_file to do shell script "echo " & license_server_file & ">>/tmp/license.srv"
Thanks for your reply.
I tried both the options. It didn’t work on Tiger OS. It is not creating the file “licence.srv”. Am I missing any syntax to set the prompted data to result or making the new file at tmp.
Please advise.
Thanks,
Rao
Would this work for you?
if the button returned of the result is "Server" then
display dialog "Enter a server: <port number>@<server name>" default answer "<port number>@<server name>"
do shell script "/bin/echo " & quoted form of text returned of result & " > /tmp/license.srv"
end if
sorry - I had an error in my script -
it was
set license_server_file to do shell script "echo " & SET license_server_file & “>>/tmp/license.srv”
should be:
set license_server_file to do shell script "echo " & license_server_file & “>>/tmp/license.srv”
Thank you guys…
Finally it works on Tiger.