Modify the program pipe1.cpp topipe1a.cpp so that it accepts a command (e.g. “ls-l”) from the keyboard. For example, when you execute “./pipe1a ps-auxw”, it should give you the same output aspipe1.cpp
//pipe1.cpp
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
FILE *fpi; //for reading a pipe
char buffer[BUFSIZ+1]; //BUFSIZ defined in <stdio.h>
int chars_read;
memset ( buffer, 0,sizeof(buffer)); //clear buffer
fpi = popen ( “ps -auxw”, “r” ); //pipe to command “ps -auxw”
if ( fpi != NULL ) {
//read data from pipe into buffer
chars_read = fread(buffer, sizeof(char), BUFSIZ,fpi );
if ( chars_read > 0 )
cout << “Output from pipe: “<< buffer << endl;
PayPal Gateway not configured
PayPal Gateway not configured