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 > As one line

As one line
Thread Tools
Addicted to MacNN
Join Date: Sep 2000
Status: Offline
Reply With Quote
Sep 8, 2001, 07:04 PM
 
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
Reply With Quote
Sep 8, 2001, 08:51 PM
 
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
Reply With Quote
Sep 9, 2001, 12:47 AM
 
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
Reply With Quote
Sep 9, 2001, 04:32 AM
 
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
Reply With Quote
Sep 9, 2001, 12:18 PM
 
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
Reply With Quote
Sep 9, 2001, 05:35 PM
 
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
Reply With Quote
Sep 9, 2001, 08:08 PM
 
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
Reply With Quote
Sep 9, 2001, 10:42 PM
 
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" -&gt; 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.

| -&gt; let's do the piping

sudo -S whoami -&gt; 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
     
   
Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 02:57 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2