Compare commits
No commits in common. "dev" and "v0.2" have entirely different histories.
3
LICENSE
3
LICENSE
@ -69,4 +69,5 @@ http://www.apache.org/licenses/LICENSE-2.0
|
|||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governin
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
48
README.md
48
README.md
@ -1,50 +1,4 @@
|
|||||||
|
# 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.
|
|
||||||
|
|
||||||
|
@ -6,14 +6,11 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace marcelb {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute bash command
|
* Execute bash command
|
||||||
*/
|
*/
|
||||||
string exec(const string& command);
|
|
||||||
|
|
||||||
}
|
string exec(const string command);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,6 +1,6 @@
|
|||||||
#include "../lib/exec.hpp"
|
#include "../lib/exec.hpp"
|
||||||
|
|
||||||
string marcelb::exec(const string& command) {
|
string exec(const string command) {
|
||||||
FILE *fds;
|
FILE *fds;
|
||||||
char cstr[200];
|
char cstr[200];
|
||||||
fds = popen(command.c_str(), "r");
|
fds = popen(command.c_str(), "r");
|
||||||
|
@ -3,12 +3,13 @@
|
|||||||
#include "../lib/exec.hpp"
|
#include "../lib/exec.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace marcelb;
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
string out = exec("ls -lha");
|
string out = exec("ls -lha");
|
||||||
|
|
||||||
cout << out << endl;
|
cout << out << endl;
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
BIN
test/test.o
BIN
test/test.o
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user