I want to execute commands within my C program. However, I need root priviliges to create some folders.I run the following:system(echo <rootpass> | sudo cd <folder> && make install);<rootpass> is given by the user (and thus the command should only execute if the user has root priviliges). However, when I run this, system returns with code 256 ( EPERM /* Operation not permitted */).How can I solve this?
C/C++: Running multiple commands as root
sudo;c
Your have to write an script, which contains expect ,sudo and make install to solve your problem and your system() function call your script such as :system(myscrip.sh);For reading expect : How to login as root from Bash and do stuff