I'm taking a Linux class and I've never done c++ before. My shell script basically does everything on its own, but I'm required to use it from a c++ program. My shell script when run from command line outputs the results I want to back to the console. When I run it from the c++ program, my program compiles and runs but I get no output. Is this because I have some error in my c++ program, or is this supposed to happen because of the way the c++ and shell script interact?
I have seen some questions about grabbing the output from the shell script and using it in the c++ program, but I don't want to do that. Literally all my c++ program does is run the shell script.
I just want the output of my shell script to show on the console. Can you help? I can post the code I'm using if needed.
C++:
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main (int argc, char *argv[]) {
string arg;
arg = string(argv[1]);
if (argc >= 2) {
for (int i=2; i < argc; i++) {
string temp = string(argv[i]);
arg=arg+" "+temp;
}
}
string command;
command = "./findName.sh "+ arg;
//cout << command;
system("command");
return 0;
}