Hello all
I just learnt about the advantages of a compiles root file vs a interpreted root file. My question is about passing parameters to the code in a unix script file.
How do I pass variables to the root file when I invoke it in a unix script. This did not work.
#! /bin/bash
root -l -b -q << EOF
.L add2num.C+
add2num(1,2,"test")
EOF
Here is the root code:
[code]#include
#include
#include <sys/stat.h>
#include <math.h>
#include
#include
#include <stdio.h>
#include <time.h>
#include
#include
#include
#include
//ROOT stuff
#include <TRandom3.h>
#include <TH1.h>
#include <TFile.h>
#include <TTree.h>
#include “TStopwatch.h”
void add2num (int a, int b, char configfile[256]) {
printf(“Ans = %i\n”,a+b);
printf(“Config file = %s”,configfile);
FILE *config=fopen(configfile,"r");
Int_t FILESTOREAD=0;
char outputlistmodefile[256];
fscanf(CONFIG,"%i",&FILESTOREAD);
fscanf(CONFIG,"%s",outputlistmodefile);
fclose(config);
}[/code]
Thanks in advance