|
|
AppleScripting Terminal
|
|
|
|
Addicted to MacNN
Join Date: Sep 2000
Status:
Offline
|
|
Ok, here is what I got:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>tell application <font color = red>"Terminal"</font>
<font color = green>do</font> script with command <font color = red>"echo PASSWORD | su root /usr/sbin/nvram boot-device=ide1/@<font color = blue>0</font>:<font color = blue>5</font>,\\:tbxi"</font>
end tell</font>[/code]
returns:
[localhost:~] robert% echo PASSWORD | su root /usr/sbin/nvram boo[localhost:~] robert% t-device=ide1/@0:5,\:tbxi
t-device=ide1/@0:5,:tbxi: Command not found.
[localhost:~] robert%
Any ideas?
I just want the script to perform the command and change the startup device.
(Security is not that much of an issue, I just don't want to give the Password to anyone)
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Escape the boot-device=ide1/@0:5,\\:tbxi like this:
do script with command "echo PASSWORD | su root '/usr/sbin/nvram boot-device=ide1/@0:5,\\:tbxi'"
Note that su root probably won't work either, I think you need to use an undocumented flag to make it read from STDIN.
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Sep 2000
Status:
Offline
|
|
ok, well then how do I give the script permission to perform the command?
Anyone know how to do this? I want users to be able to switch into Mac OS 9 (for apps that don't work in X yet) but I don't want everyone to have an admin password (which is needed if I use the system preferences method for switching.
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: May 2001
Status:
Offline
|
|
"sudo -S" takes the password from standard input. Something like this should work (double-quoting the boot-device probably isn't necessary, but couldn't hurt):
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>set thePassword to text returned of (display dialog <font color = red>"Please enter your user password..."</font> default answer <font color = red>""</font>)
tell application <font color = red>"Terminal"</font>
do script with command <font color = red>"echo "</font> & thePassword & <font color = red>" | sudo -S /usr/sbin/nvram boot-device=\"</font>ide1/@<font color = blue>0</font>:<font color = blue>5</font>,\\:tbxi\<font color = red>""</font>
end tell</font>[/code]
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Sep 2000
Status:
Offline
|
|
Here is what I did:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
--set thePassword to text returned of (display dialog <font color = red>"Please enter your user password..."</font> default answer <font color = red>""</font>)
set ask_dlog to display dialog <font color = red>"Do you wish to switch to Mac OS <font color = blue>9.2</font>.<font color = blue>1</font>?"</font> buttons {<font color = red>"Yes"</font>, <font color = red>" No "</font>} default button <font color = red>"Yes"</font> with icon note
if button returned of ask_dlog is <font color = red>"Yes"</font> then
tell application <font color = red>"Terminal"</font>
do script with command <font color = red>"echo "</font> & <font color = red>"PASSWORD GOES HERE"</font> & <font color = red>" | sudo -S /usr/sbin/nvram boot-device=\"</font>ide1/@<font color = blue>0</font>:<font color = blue>5</font>,\\:tbxi\<font color = red>""</font>
end tell
set fin_dlog to display dialog <font color = red>"Sucessful, the next time you restart, you will boot in Mac OS <font color = blue>9</font>, do you wish to restart now?"</font> buttons {<font color = red>"Yes"</font>, <font color = red>" No "</font>} with icon note
if button returned of fin_dlog is <font color = red>"Yes"</font> then
tell application <font color = red>"Finder"</font>
restart
end tell
end if
if button returned of fin_dlog is <font color = red>" No "</font> then
end if
end if
if button returned of ask_dlog is <font color = red>" No "</font> then
end if
</font>[/code]
Great
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|