33 void showFile(
const char *fn, 
int show, 
int keep);
    43 int main(
int argc, 
char **argv)
    47    if (argc > 1 && !strcmp(argv[1],
"-h")) {
    49       printf(
" PQ2 functionality\n");
    53       printf(
" $ ./pq2 [-h] [-v] [-k] <action> [-d datasetname|datasetfile] [-s server] -u serviceurl\n");
    55       printf(
" Arguments:\n");
    56       printf(
"   -h            prints this menu\n");
    57       printf(
"   -v            verbose mode\n");
    58       printf(
"   -k            keep temporary files\n");
    59       printf(
"   <action>      ls, ls-files, ls-files-server, info-server, put, rm, verify\n");
    60       printf(
"   datasetname   Name of the dataset; the wild card '*' is accepted: in \n");
    61       printf(
"                 such a case the full path - as shown by pq2-ls - must \n");
    62       printf(
"                 be given in quotes, e.g. \"/default/ganis/h1-set5*\"\n");
    63       printf(
"                 (applies to: ls-files, ls-files-server, rm, verify\n");
    64       printf(
"   datasetfile   Path to the file with the list of files in the dataset or \n");
    65       printf(
"                 directory with the files containing the file lists of the \n");
    66       printf(
"                 datasets to be registered; in the first case wildcards '*' \n");
    67       printf(
"                 can be specified in the file name, i.e. \"<dir>/fil*\" is ok \n");
    68       printf(
"                 but \"<dir>/*/file\" is not. In all cases the name of the \n");
    69       printf(
"                 dataset is the name of the file finally used\n");
    70       printf(
"                 (applies to: put)\n");
    71       printf(
"   server        Name of the server for which the information is wanted; can be in \n");
    72       printf(
"                 URL form \n");
    73       printf(
"                 (applies to: ls-files-server, info-server)\n");
    74       printf(
"   serviceurl    entry point of the service to be used to get the information (PROOF master\n");
    75       printf(
"                 or data server) in the form '[user@]host.domain[:port]'\n");
    81    const char *action = 0;
    83    const char *dataset = 0;
    84    const char *servers = 0;
    85    const char *options = 0;
    86    const char *ignsrvs = 0;
    87    const char *excsrvs = 0;
    91    const char *infile = 0;
    92    const char *outfile = 0;
    93    const char *redir = 0;
    96       if (!strcmp(argv[i],
"-h")) {
    99       } 
else if (!strcmp(argv[i],
"-d")) {
   100          if (i+1 == argc || argv[i+1][0] == 
'-') {
   101             Printf(
" -d should be followed by a string: ignoring");
   107       } 
else if (!strcmp(argv[i],
"-o")) {
   108          if (i+1 == argc || argv[i+1][0] == 
'-') {
   109             Printf(
" -o should be followed by a string: ignoring");
   115       } 
else if (!strcmp(argv[i],
"-e") ||!strcmp(argv[i],
"--exclude") ) {
   116          if (i+1 == argc || argv[i+1][0] == 
'-') {
   117             Printf(
" -e or --exclude should be followed by a string: ignoring");
   123       } 
else if (!strcmp(argv[i],
"-i") ||!strcmp(argv[i],
"--ignore") ) {
   124          if (i+1 == argc || argv[i+1][0] == 
'-') {
   125             Printf(
" -i or --ignore should be followed by a string: ignoring");
   131       } 
else if (!strcmp(argv[i],
"-s") || !strcmp(argv[i],
"--servers")) {
   132          if (i+1 == argc || argv[i+1][0] == 
'-') {
   133             Printf(
" -s or --servers should be followed by a string: ignoring");
   139       } 
else if (!strcmp(argv[i],
"-m")) {
   140          if (i+1 == argc || argv[i+1][0] == 
'-') {
   141             Printf(
" -m should be followed by a string: ignoring");
   147       } 
else if (!strcmp(argv[i],
"-f")) {
   148          if (i+1 == argc || argv[i+1][0] == 
'-') {
   149             Printf(
" -f should be followed by a string: ignoring");
   155       } 
else if (!strcmp(argv[i],
"-r")) {
   156          if (i+1 == argc || argv[i+1][0] == 
'-') {
   157             Printf(
" -r should be followed by a string: ignoring");
   163       } 
else if (!strcmp(argv[i],
"-u")) {
   164          if (i+1 == argc || argv[i+1][0] == 
'-') {
   165             Printf(
" -u should be followed by a string: ignoring");
   171       } 
else if (!strcmp(argv[i],
"--plot")) {
   172          if (i+1 == argc || argv[i+1][0] == 
'-') {
   179       } 
else if (!strcmp(argv[i],
"--infile")) {
   180          if (i+1 == argc || argv[i+1][0] == 
'-') {
   181             Printf(
" --infile should be followed by a string: ignoring");
   187       } 
else if (!strcmp(argv[i],
"--outfile")) {
   188          if (i+1 == argc || argv[i+1][0] == 
'-') {
   189             Printf(
" --outfile should be followed by a string: ignoring");
   195       } 
else if (!strncmp(argv[i],
"-v",2)) {
   197          if (!strncmp(argv[i],
"-vv", 3)) 
gverbose++;
   198          if (!strncmp(argv[i],
"-vvv", 4)) 
gverbose++;
   200       } 
else if (!strncmp(argv[i],
"-k",2)) {
   209       Printf(
"Specifying an action is mandatory - exit");
   216    const char *actions[nact] = { 
"ls", 
"ls-files", 
"ls-files-server",
   217                                  "info-server", 
"put", 
"rm", 
"verify",
   218                                  "ana-dist", 
"cache" };
   219    const char *tags[nact]    = { 
"ls", 
"lsfiles", 
"filessrv",
   220                                  "infosrv", 
"put", 
"rm", 
"vfy", 
"anadist", 
"cache" };
   223    for (i = 0; i < nact; i++) {
   224       if (action && !strcmp(action, actions[i])) {
   230       Printf(
"Unknown action: %d (%s)", iact, action ? action : 
"");
   239       if (!(tdir.EndsWith(ug->fUser))) {
   240          if (!(tdir.EndsWith(
"/"))) tdir += 
"/";
   246       Printf(
"Could create temp directory at: %s", tdir.Data());
   249    flog.
Form(
"%s/pq2%s.log", tdir.Data(), tag);
   250    ferr.
Form(
"%s/pq2%s.err", tdir.Data(), tag);
   251    fres.
Form(
"%s/pq2%s.res", tdir.Data(), tag);
   260       TString dsmgracts = getenv(
"PQ2DSSRVACTS") ? getenv(
"PQ2DSSRVACTS")
   261                                                  : 
"ls:lsfiles:filessrv:infosrv:anadist:cache:" ;
   264       if (dsmgracts.
Contains(atag) && getenv(
"PQ2DSSRVURL")) {
   265          url = getenv(
"PQ2DSSRVURL");
   266       } 
else if (getenv(
"PROOFURL") || getenv(
"PQ2PROOFURL")) {
   267          url = getenv(
"PQ2PROOFURL") ? getenv(
"PQ2PROOFURL") : getenv(
"PROOFURL");
   270          Printf(
"Specifying a service URL is mandatory - exit");
   274    if (
gverbose > 0) 
Printf(
"Checking URL: %s", url ? url : 
"--undef--");
   277       Printf(
"Specified URL does not identifies a running service: %s", url);
   285          do_ls(dataset, options);
   287       } 
else if (iact == 1) {
   291       } 
else if (iact == 2) {
   295       } 
else if (iact == 3) {
   299       } 
else if (iact == 4) {
   303       } 
else if (iact == 5) {
   307       } 
else if (iact == 6) {
   311       } 
else if (iact == 7) {
   313          do_anadist(dataset, servers, ignsrvs, excsrvs, metrics, fout, plot, outfile, infile);
   315       } 
else if (iact == 8) {
   317          bool clear = (options && !strcmp(options, 
"clear")) ? 1 : 0;
   322          Printf(
"Unknown action code: %d - Protocol error?", iact);
   325    catch (std::exception& 
exp) {
   326       Printf(
"Standard exception caught: '%s' - We exit whatever it is ...", exp.what());
   329    catch (
const char *str) {
   330       Printf(
"Exception thrown: %s", str);
   334       Printf(
"Handle uncaugth exception, terminating");
   344       Printf(
"Temporary files kept: ");
   358    if (fn && strlen(fn)) {
   361          Printf(
"File '%s' cannot be stated or is not regular: ignoring", fn);
 
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode. 
void do_anadist(const char *ds, const char *servers, const char *ignsrvs, const char *excsrvs, const char *metrics, const char *fnout, const char *plot, const char *outfile, const char *infile)
Execute 'analyze-distribution' for the dataset(s) described by 'ds'. 
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time. 
Class supporting a collection of lines with C++ code. 
void do_rm(const char *dsname)
Execute 'rm'. 
Bool_t R_ISREG(Int_t mode)
virtual int mkdir(const char *name, Bool_t recursive=kFALSE)
Make a file system directory. 
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file. 
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
virtual void Print(Option_t *option="") const
Print contents of this macro. 
virtual UserGroup_t * GetUserInfo(Int_t uid)
Returns all user info in the UserGroup_t structure. 
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in. 
R__EXTERN TSystem * gSystem
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor. 
void do_info_server(const char *server)
Execute 'info-server'. 
void do_cache(bool clear, const char *ds)
Execute 'cache'. 
int main(int argc, char **argv)
int do_verify(const char *dsname, const char *opt, const char *redir)
Execute 'verify'. 
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Int_t checkUrl(const char *url, const char *flog, bool def_proof)
Check if something is running at gUrl Return 0 if OK and data server 1 if OK and PROOF server -1 if n...
void showFile(const char *fn, int show, int keep)
Display the content of file 'fn'. 
virtual Int_t GetUid(const char *user=0)
Returns the user's id. If user = 0, returns current user's id. 
void do_put(const char *files, const char *opt)
Execute 'put'. 
virtual void Exit(int code, Bool_t mode=kTRUE)
Exit the application. 
void do_ls(const char *ds, const char *opt)
Execute 'ls'. 
void do_ls_files_server(const char *ds, const char *server)
Execute 'ls-files'. 
const char * Data() const