I have a shell script that goes as follows:
#!/bin/sh
TESTOUTDIR=/home/speedster/test_dir
echo "Hello"
echo $TESTOUTDIR
When I run this directly from the command line, it prints "Hello" and the TESTOUTDIR variable which I have set as expected.
Now I am running this from a C++ program. My program is as follows:
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
string runCommand = "/test.sh";
system(runCommand.c_str());
}
When I run this I get the output as only "Hello". The variable is not getting printed. What can I do to fix this?