run unix "system" command as root - Unix

This is a discussion on run unix "system" command as root - Unix ; Hi folks , i have set of commands , which i want to run in run time , as a root user . so , can somebody tell me , how to run unix "system" command as root from C++ ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: run unix "system" command as root

  1. run unix "system" command as root


    Hi folks ,

    i have set of commands , which i want to run in run time , as a root
    user .

    so , can somebody tell me , how to run unix "system" command as root
    from C++ code //


    regards
    Aki






  2. Re: run unix "system" command as root

    aki writes:

    > Hi folks ,
    >
    > i have set of commands , which i want to run in run time , as a root
    > user .
    >
    > so , can somebody tell me , how to run unix "system" command as root
    > from C++ code //


    Well, the simplest way is just to run your C++ program as root; then the
    commands run by system() will also be run as root.

    Another possibility is to do something along the lines of

    system("sudo command");

    Depending on your system and desktop environment, there might be nice
    GUI programs that will pop up a password prompt, which you could use in
    place of sudo. Not sure what they're called, though.

    Will any of those work for you?

+ Reply to Thread