Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > AppleScripting Terminal

AppleScripting Terminal
Thread Tools
macvillage.net
Addicted to MacNN
Join Date: Sep 2000
Status: Offline
Reply With Quote
Sep 30, 2001, 11:21 AM
 
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)
     
Angus_D
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Oct 3, 2001, 02:59 PM
 
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.
     
macvillage.net  (op)
Addicted to MacNN
Join Date: Sep 2000
Status: Offline
Reply With Quote
Oct 20, 2001, 01:30 PM
 
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.
     
acur128
Junior Member
Join Date: May 2001
Status: Offline
Reply With Quote
Oct 20, 2001, 10:16 PM
 
"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]
     
macvillage.net  (op)
Addicted to MacNN
Join Date: Sep 2000
Status: Offline
Reply With Quote
Oct 21, 2001, 02:39 PM
 
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 Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 08:27 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,