In order to run some procedures I have to run multiple unix codes which are all programs written in the computer. For example:
: ../../bin/takeData -l -dir ../../Working_Directory -trimVcal 60
then after that is ran I'd have to run
: cd ../convert_to_tree
: ./convert_to_tree XXXX
: ./pulseHeightMain XXXX
: cd ~/log/bt0500XXXX
etc.
the XXXX represents a test run number. What I want to do is be able to type a program that would look like this:
: ./AquireData -dir Working_Directory -run XXXX
that would run all above and more. AquireData would be the C++ file. What I have so far is:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char* argv[]) {
string file_name;
string run_num;
string config_file;
int opt = 0;
for (int i = 1; i < argc; i++) {
if (i + 1 != argc)
if (argv == "-dir") {
file_name = argv[i + 1];
} else if (argv == "-run") {
run_num = argv[i + 1];
} else if (argv == "-mask") {
opt = 1;
} else if (argv == "-cfg") {
config file = argv[i+1];
}
std::cout << argv << " ";
}
if (opt == 0){
// Unix commands for unmasked
}
if (opt == 1){
// Unix commands for unmasked
}
return 0;
}
Here is my two main questions:
-
When I'm in the directory what would I type with the arguments to compile and run the c++ code and read the argument line? and can I make it look like how I wanted to above?
-
How to I put unix commands in c++ so I could have something like:
cd ~/log/bt0500 << run_num
Note: I haven't used C++ in awhile so some of the easy stuff has slipped past me, but also the reason I'm using c++ is because a shell command script like AquireData.C wouldn't be able to input directory, run number, and other options, or would it?