My is c++ is for running multiple algorithms with different parameters a,b,c that has to be send when executing algorithms 1,2,3. In each run, I need to change a,b, c. The results of each different run is saved in Excel file.
My professor suggested that instead of manually running the c++ program and changing the parameters in each run, It is useful for me to write a batch file and let it run for one day then I will have considerable amount of results in the Excel file.
How could I write a batch file in Linux(Ubuntu)? Is there any example or tutorial that I can start from?
This looks like just a tutorial for writing shell scripts, which you can use to batch commands, but there are some issues in it.
> Once you have prepared your batch file, you will have to save the file with any name, but with the extension ‘.sh’ at the end of the file name.
This is not correct. A shell script doesn't need to end in .sh, and if it's something you intend to run from the command line, it probably shouldn't have an extension at all (you don't run ls.elf or zgrep.sh).
The quotes are also the special curly quote character, and not the actual quote character.
this is a great skill to have, but I have to ask why you can't put a loop in main() that does the same thing with less trouble?
I kind of have a mental wall or breakpoint. If its too complex, I will write an 'evil' system() riddled c++ "batch file" or whatever you want to call it that mixes OS calls and C++ code to do the task. If it is trivial, I will do a batch or shell script instead. The c++ ones COULD be done in shell scripting or batch, but I am not a master of those things and I can get it done faster in c++, with less clunk. Just an alternative or hybrid idea or two for you. Also, as an intermediate at best scripter, I frequently just dump one command to text and feed it to the next from a file. I know you can do it with pipes, but I can't see what went wrong as easily as I can checking the offending text file. It is very helpful for debugging, if you want to change the files to pipes later, you can.
> why you can't put a loop in main() that does the same thing with less trouble?
because it is not «less trouble»
your program already works, it solves the problem that it needs to solve. no need to bloat it with a lot of functions that the end user may never use.
you want to «test a lot of configurations», that's a different problem, so a different program may hold that responsibility.
if you want to code that wrapper in c, go ahead