This c++ application displays a menu, accepts selected option and executes the associated executable or script.
The source code in included below.
[codesyntax lang=”cpp”]
//============================================================================ // Name : op1.cpp // Author : Mr. Arch Brooks // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include <iostream> using namespace std; /* * This function allows for the execution of any executable * and script on the operating system. * * It is designed to execute the command without waiting for completion. */ void Xqt(string cmd) { // @suppress("Type cannot be resolved") const char * c = cmd.c_str(); // @suppress("Method cannot be resolved") system(c); // @suppress("Invalid arguments") // @suppress("Function cannot be resolved") } /* * Our main routine displays the menu, examines the option selected * and executes the script or executable associated with the option */ int main() { string mystr; string cmd; /* * Clear the screen */ cmd = "clear"; Xqt(cmd); /* * Display the menu */ cout << " 1 Named.Conf.Options " << endl; cout << " 2 Named.Conf.Options.Local " << endl; cout << " 3 Named.Conf.Options.Default-Zones " << endl; cout << " 4 DB.Localhost.com " << endl; cout << " 5 DB.109 " << endl; cout << " 6 Restart Bind " << endl; cout << " 7 Restart DOvecot and Postfix " << endl; /* * Get selection from user */ cmd = ""; getline(cin, mystr); if (mystr == "1") { cmd = "nano /etc/bind/named.conf.options"; } if (mystr == "2") { cmd = "nano /etc/bind/named.conf.options.local"; } if (mystr == "3") { cmd = "nano /etc/bind/named.conf.default-zones"; } if (mystr == "4") { cmd = "nano /etc/bind/db.localhost.com"; } if (mystr == "5") { cmd = "nano /etc/bind/db.109"; } if (mystr == "6") { cmd = "/etc/bind/gob"; } if (mystr == "7") { cmd = "/root/rm"; } /* * If no valid command was accepted execute nothing */ if (cmd > "") { Xqt(cmd); } /* * Clear the screen */ cmd = "clear"; Xqt(cmd); return 0; }
[/codesyntax]
This application offers some relief from pounding the command line. The server has zero graphical user interface capability available.
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems, LLC authored this article.