Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

ExitWindowsEx equivalent in LINUX

Hi. I`ve been using ExitWindowsEx() function to programmatically shutdown computers running Windows. Is there an equivalent function call (in C/C++) to shutdown linux computers?

Thanks for the reply


eating

Comments

  • IDKIDK Member Posts: 1,784
    : Hi. I`ve been using ExitWindowsEx() function to programmatically shutdown computers running Windows. Is there an equivalent function call (in C/C++) to shutdown linux computers?
    :
    : Thanks for the reply
    :
    :
    : eating
    :
    system("shutdown now"); will do it I think. I don't know C/C++ or linux but I think it's right.

    Happy coding wishes
    the one and only
    [b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]

  • eating_jpeating_jp Member Posts: 2
    Thanks for that quick reply. However it doesnt work? I haven:t tried logging in as root, though. But i need a utility for "ordinary" users to shutdown the computer.

    I have tried init(), shutdown(), reboot()...these just doesnt work. =(

    : : Hi. I`ve been using ExitWindowsEx() function to programmatically shutdown computers running Windows. Is there an equivalent function call (in C/C++) to shutdown linux computers?
    : :
    : : Thanks for the reply
    : :
    : :
    : : eating
    : :
    : system("shutdown now"); will do it I think. I don't know C/C++ or linux but I think it's right.
    :
    : Happy coding wishes
    : the one and only
    : [b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]
    :
    :

  • satharielsathariel Member Posts: 59
    : Thanks for that quick reply. However it doesnt work? I haven:t tried logging in as root, though. But i need a utility for "ordinary" users to shutdown the computer.
    :
    : I have tried init(), shutdown(), reboot()...these just doesnt work. =(
    :
    : : : Hi. I`ve been using ExitWindowsEx() function to programmatically shutdown computers running Windows. Is there an equivalent function call (in C/C++) to shutdown linux computers?
    : : :
    : : : Thanks for the reply
    : : :
    : : :
    : : : eating
    : : :
    : : system("shutdown now"); will do it I think. I don't know C/C++ or linux but I think it's right.
    : :
    : : Happy coding wishes
    : : the one and only
    : : [b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]
    : :
    : :
    :
    :

    Hi,

    you can use one exec-call to execute the system-call of shutdown (man exec). You should set the compiled programs suid-flag so it will run as root, e.g.
    [code]
    chown root myshutdownprog
    chmod 1755 myshutdownprog
    [/code]
    Consult some manpages and do some searches in the internet to find some more hints.
    Normally shutdown is an administrative task (you don't want one user out of 1000 to be able to shut down your server ;) ).
    [black]SaThaRiel[/black]

    [size=1][blue]Any time things appear to be going better, you have overlooked something.[/blue][/size]

Sign In or Register to comment.