Snow Leopard sudo: no tty present error message problem

As I’m not that versed in using shell scripts I am hoping someone can help me with a problem that has come up.
Before Snow Leopard I used the following command:
do shell script “echo PASSWORD | sudo chmod 0 /System/Library/CoreServices/TheApplicationTargeted”

but now I get the error message:
error “sudo: no tty present and no askpass program specified” number 1

I read somewhere that recent versions of sudo will refuse to prompt for a password if no
tty is present, but I’m not quite sure what that means or how to rewrite my command to solve the problem.

I thank you for your time and I look forward to hearing back from anyone who can help.:slight_smile:

I usually figure this stuff out by experimenting with what I’m trying to do, but it’s a little dangerous to be doing SUDO anything, and this definately includes changing the permissions for anything in your /System/ folder.

What/why are you trying to do this?

Thank you elspub for the reply and I apologize for being slow in getting back to you. I should also apologize for the obviously confusing example I gave. It just so happened to be what first caught my eye but I should have used something else. The reason I was adjusting permissions in the System Folder was because I am running a Kiosk style setup where the only program running is my own (right from startup). I had asked a fellow programmer a few years back for a good way to disable Spotlight and he told me to change the permissions so that it wouldn’t start up in the account I was using. (In Snow Leopard the Spotlight feature has changed from being an app in the CoreServices Folder to…well, to something else.) Anyway, that method worked before, but that style of coding seems to have changed in Snow Leopard. For example (a better one than before):

set posixPath1 to quoted form of POSIX path of “HardDisk:Test_1:”
set posixPath2 to quoted form of POSIX path of “HardDisk:Test_2:”

do shell script "echo admin_password | sudo mv " & posixPath1 & "* " & posixPath2

This worked before, but now in Snow Leopard I get the error message:

sudo: no tty present and no askpass program specified

I was able to work around it (in a sense problem solved) by using:

do shell script "mv " & posixPath1 & "* " & posixPath2 user name admin_name password admin_password with administrator privileges

Even though this works fine, I am confused as to why the sudo style stopped working.

Any ideas?

Thanks again for your time and I look forward to hearing back from you soon.:rolleyes:

Don’t use sudo; see http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html for how to do it.

Thanks Shane for the link.:smiley: