Compare commits

...

3 Commits
v0.2 ... dev

Author SHA1 Message Date
marcelb
a98c429f54 Readme, license swap fix 2024-01-07 21:36:49 +01:00
marcelb
9f23666738 Readme, comments, reference 2024-01-07 21:34:03 +01:00
marcelb
cd295a93b6 Readme, comments 2024-01-07 21:33:04 +01:00
6 changed files with 55 additions and 8 deletions

View File

@ -69,5 +69,4 @@ http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
See the License for the specific language governin

View File

@ -1,4 +1,50 @@
# Library for executing bash commands with captured output.
# Library for executing bash commands with captured output
The output of the bash command is saved in a C++ string.
The output of the bash command is saved in a C++ string.
## Features
- Execute command send as string
- Return string as command response
- Thread safe
- Throws an exception when cant pipe stream in execute command
## Installation
Just download the latest release and unzip it into your project. You can turn it on with:
```
#include "exec/lib/exec.hpp"
using namespace marcelb;
```
## Usage
```c++
/**
* Run bash command and store output
*/
string out = exec("ls -lha");
/**
* Print response
*/
cout << out << endl;
```
## License
[APACHE 2.0](http://www.apache.org/licenses/LICENSE-2.0/)
## Support & Feedback
For support and any feedback, contact the address: marcelb96@yahoo.com.
## Contributing
Contributions are always welcome!
Feel free to fork and start working with or without a later pull request. Or contact for suggest and request an option.

View File

@ -6,11 +6,14 @@
using namespace std;
namespace marcelb {
/**
* Execute bash command
*/
string exec(const string& command);
string exec(const string command);
}
#endif

View File

@ -1,6 +1,6 @@
#include "../lib/exec.hpp"
string exec(const string command) {
string marcelb::exec(const string& command) {
FILE *fds;
char cstr[200];
fds = popen(command.c_str(), "r");

View File

@ -3,13 +3,12 @@
#include "../lib/exec.hpp"
using namespace std;
using namespace marcelb;
int main() {
string out = exec("ls -lha");
cout << out << endl;
return 0;
}

Binary file not shown.