Using C++ for System Administration tasks

When a system administrator (especially someone managing Linux-based systems) needs to do things repeatedly, it is common sense that he will write bash-scripts for such things.

But for many reasons, I like to know how such things can be done in C++, like:

*) Managing folders/files
*) Managing system users
*) Managing certificates
*) Managing system packages (wether pacman, apt-get or yum)
*) Etc, etc.

What are considered safe ways to invoke things like these within C++? Most tools do have usefull libraries, but there are ones that don't.

Also, I read C++ has lack of good encoding support. (http://programmers.stackexchange.com/questions/179620/benefit-of-c-to-system-administrators)

I want to go for C++ since it's a compiled language, and therefore I can choose to make something closed source, so a scripted language doesn't make sense in this case.
So you know about scripting languages, and from reason you prefer a compiled language for sysadmin tasks...

Neither the core C++ nor C language is the issue here.

Your problem is one of interfacing with the system.

C is the interface!

All the shell commands eventually end up calling a program that was written in C.

All the system calls are implemented in C

So, even if you wrote your program in Python, eventually everything you accomplish will pass through some sort of C layer.

Fortunately these interfaces are available directly in C on Linux based systems, and all you need do, is include the right header, and make the right function call, either from C or C++.

Try the man pages for help (be sure to have manpages-posix-dev installed) for example, "man 3 mkdir" will show you how to create a directory using C (or C++)

Most of the packages have a "dev" version that lets you access their API directly from your C or C++ programs

RTFM
Topic archived. No new replies allowed.