Results 1 to 3 of 3
  1. #1

    Member Since
    Oct 09, 2009
    terminal command with password
    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!

  2. #2

    Raz0rEdge's Avatar
    Member Since
    Jul 17, 2009
    27" i7 iMac, 24" iMac, 13" Macbook Air, iPhone 5 & 5S, iPod Nano 7th Gen, iPad 2 16GB WiFi, iPad 3
    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
    sudo visudo
    which will take you to a file that controls how SUDO functions. Towards the bottom you'll see something like #
    %wheel ALL=(ALL) NOPASSWD: ALL
    so you could add something like the following
    <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..


  3. #3

    Member Since
    Oct 09, 2009
    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?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Terminal command help.
    By ladylisak in forum OS X - Operating System
    Replies: 2
    Last Post: 10-18-2013, 01:47 PM
  2. Terminal 'ls' Command Help
    By xxSwagPanda in forum OS X - Operating System
    Replies: 1
    Last Post: 03-26-2013, 11:18 PM
  3. Please help me with this Terminal command
    By nowakchr in forum OS X - Operating System
    Replies: 2
    Last Post: 12-12-2010, 10:39 AM
  4. terminal command help
    By ytbryan in forum OS X - Development and Darwin
    Replies: 2
    Last Post: 09-18-2009, 05:22 PM
  5. cd Terminal Command
    By Mac_Daddy in forum OS X - Operating System
    Replies: 4
    Last Post: 11-19-2007, 09:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts