New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
Switcher Hangout The place for switchers to discuss their new machines, and how to work with OS X. General support can be had here for newbie stuff, like "How do I restart my new iMac?" :)

terminal command with password


Post Reply New Thread Subscribe

 
Thread Tools
vdfoo

 
Member Since: Oct 09, 2009
Posts: 2
vdfoo is on a distinguished road

vdfoo is offline
Hi, I'm new the development in Mac. I need to call a command line as following using C++ with system() function:
"sudo rm /private/var/db/.AccessibilityAPIEnabled"
I'm expecting this line being executed in background, however in my C++ console application, it would prompt for a password, I need to eliminate this step. Is there something like "sudo rm /private/var/db/.AccessibilityAPIEnabled -p MyPassword" in Mac?
Thanks a lot!
QUOTE Thanks
Raz0rEdge

 
Raz0rEdge's Avatar
 
Member Since: Jul 17, 2009
Location: MA
Posts: 7,433
Raz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant futureRaz0rEdge has a brilliant future
Mac Specs: 27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3

Raz0rEdge is offline
To run a SUDO command without using your password, you can configure SUDO to allow a particular (or all) commands to be run without the password.

So do
Quote:
sudo visudo
which will take you to a file that controls how SUDO functions. Towards the bottom you'll see something like #
Quote:
%wheel ALL=(ALL) NOPASSWD: ALL
so you could add something like the following
Quote:
<username> ALL=(ALL) NOPASSWD: rm
and it will allow you to do the rm as SUDO without requiring a password.

Note that this means ANY rm you do will no longer require a password, so it might be dangerous..

Regards
QUOTE Thanks
vdfoo

 
Member Since: Oct 09, 2009
Posts: 2
vdfoo is on a distinguished road

vdfoo is offline
thanks Raz0rEdge, i tried it, it works. however this might not be a perfect solution to my problem. i'm using a C++ app to call a command as such: "sudo rm /private/var/db/.AccessibilityAPIEnabled". i'm looking for a way to in-build the admin password into the command. i agree with you that adding "<username> ALL=(ALL) NOPASSWD: rm" would be dangerous, therefore i think this way is not a good approach to my problem. is there a way that i can skip the password prompt only in my app?
QUOTE Thanks

Post Reply New Thread Subscribe


« How much of a MBP would I need? | I just got two monitors! »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting 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 Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Terminal Password Errors tlpascoe OS X - Operating System 0 09-09-2009 06:01 PM
Mac doesn't recognize airport password Jasmine Rice Internet, Networking, and Wireless 5 05-23-2009 04:48 PM
Can't Type Password in Terminal WriterStitch OS X - Operating System 2 04-18-2009 02:31 AM
Use Applescript to run a terminal command Turk182 OS X - Development and Darwin 1 02-12-2009 12:08 PM
Applescript to input terminal Password db2six9 OS X - Operating System 2 12-01-2008 10:36 PM

All times are GMT -4. The time now is 06:52 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?