 |
 |
As one line
|
 |
|
 |
|
Addicted to MacNN
Join Date: Sep 2000
Status:
Offline
|
|
I am writing a simple applescript to change the startup disk. but I have one problem...
How can I write the following as one line so that I don't get prompted for a password?
sudo /usr/sbin/nvram boot-device=ide1/@0:5,\\:tbxi
just like you can use username  assword@ftp.domain.com to get into a ftp site, is there a way to sudo without getting prompted for a password separately?
|
I always use protection when fscking my Mac... Do you?
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status:
Offline
|
|
From sudo's man page
-S The -S (stdin) option causes sudo to read the password
from standard input instead of the terminal device.
So now all you have to do is have ur applescript write the password u want to stdin after u execute that one line of code. Of course I'm not sure how to do that, but it can't be that hard.
HTH,
F-bacher
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Mar 2001
Status:
Offline
|
|
Originally posted by macvillage.net:
<STRONG>I am writing a simple applescript to change the startup disk. but I have one problem...
How can I write the following as one line so that I don't get prompted for a password?
sudo /usr/sbin/nvram boot-device=ide1/@0:5,\\:tbxi
just like you can use username  assword@ftp.domain.com to get into a ftp site, is there a way to sudo without getting prompted for a password separately?</STRONG>
Just like this:
echo "thePassword" | sudo -S whoami
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Uhm... YUCK YUCK YUCK. Password as plaintext, anybody?
It would be better to create a shell script, and then make that setuid(root). There are directions on how to do this in the archive you can get the search page to work 
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Sep 2000
Status:
Offline
|
|
Originally posted by Angus_D:
<STRONG>Uhm... YUCK YUCK YUCK. Password as plaintext, anybody?
It would be better to create a shell script, and then make that setuid(root). There are directions on how to do this in the archive you can get the search page to work  </STRONG>
Well, I am going to compile the script as read only, and it's only on my computer as a shortcut, so it's not a big security issue.
|
I always use protection when fscking my Mac... Do you?
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Sep 2000
Status:
Offline
|
|
How about for su instead of sudo?
I am using OSX PowerAddOns
As for:
echo "thePassword" | sudo -S whoami
Did anyone get what this is for?
|
I always use protection when fscking my Mac... Do you?
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Mar 2001
Status:
Offline
|
|
Originally posted by macvillage.net:
<STRONG>
As for:
echo "thePassword" | sudo -S whoami
Did anyone get what this is for?</STRONG>
I thought it was what you were asking for. That command will pass thePassword to sudo (As the Password) and then run the command whoami.
So to run your command, you would do:
echo "thePassword" | sudo -S /usr/sbin/nvram boot-device=ide1/@0:5,\\:tbxi
If that doesn't answer the question then I have misunderstood your question.
[ 09-09-2001: Message edited by: unregistered ]
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Dec 2000
Location: Chicago, Illinois
Status:
Offline
|
|
It does exactly what you want, if you don't want to get into too much detail  Essentially this is what unix people call piping, or taking the output of one command and sending it into the input stream of another.
The way to read this (I think) is:
echo "thePassword" -> the command echo takes the argument "thePassword" and just prints it to stdout... except that there's a pipe, so it goes to the input stream of the next command.
| -> let's do the piping
sudo -S whoami -> the sudo command su's (changes users to) the user whoami, whose password is obtained fromt STDIN... but because there was a pipe, that's from the previous command.
I hope that made some sense,
F-bacher
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|