Run a C++ program in Clion as root

前端 未结 5 1982
逝去的感伤
逝去的感伤 2021-02-14 03:38

I\'m trying to run a program written in C++ by using CLion v1.2 as super user. Anyone here knows how to run it as superuser? I\'m using CMake.

5条回答
  •  孤街浪徒
    2021-02-14 04:11

    You can create a bash script to help you. For example, run.sh:

    #!/usr/bin/env bash
    echo $LOGIN_PASSWD | sudo -S yourExecutable --with=some-arguments
    

    Don't forget to chmod a+x run.sh, and export the password of current account as an environment variable in Run/Debug Configurations.

提交回复
热议问题