[Gate-users] execution of a file

David Boersma david.boersma at acmit.at
Thu May 7 12:01:54 CEST 2020


Hi!


Actually, if you really, really want to be able to have "executable mac files" that are run by Gate without having to explicitly type Gate yourself, then you can use the UNIX shell convention that if the first line in a text file starts with a shebang ("#!") then the rest of the first line is interpreted as the command that should be used to execute the file. This convention is used e.g. in bash scripts that start with "#!/bin/bash" or python scripts that start with "#!/usr/bin/env python". In order to make that mechanism work for Gate macros, you need to add the following line as the very first line in your main macro:


#!/usr/bin/env Gate


Then if you make the macro file executable (using "chmod a+x mac/main.mac" as described in the link given by the original poster) then you can indeed run the macro like an executable script (enter "./mac/main.mac" in the command line).


Note:

  *   Of course this trick only works if your shell environment is configured for running Gate. That is, the Gate executable can be found in one of the $PATH directories, and the corresponding "geant4.sh" and "thisroot.sh" have been "sourced".
  *   If you put that Gate line on the second, third, etc any other line than the first line of your macro, then it  won't work.
  *   This way you cannot use any other Gate command line arguments on the actual command line. In particular you can't dynamically set aliases with the "-a" option. You could of course still append the "-a" options to the first line, but then you have to change the file in order to run with different alias values, so you can't call that "dynamically setting" any more.
  *   Maybe this trick can also help to allow start Gate via "point and click" on a mac file in a file browser. I am not a point-and-click person, I'll leave this as an exercise to whoever is interested in such an interface. This could be nice in combination with the Qt GUI (use "#!/usr/bin/env Gate --qt" as the first line and make sure that the visualization options are properly set).
  *   This is just a trick, a curiosity. The normal way to run a Gate macro is still to enter the "Gate [options] yourmacro.mac" in a terminal window.

Enjoy,
David
________________________________
Von: Gate-users <gate-users-bounces at lists.opengatecollaboration.org> im Auftrag von Maxime Toussaint <Maxime.Toussaint at USherbrooke.ca>
Gesendet: Montag, 4. Mai 2020 06:30:25
An: Muhammad Afzaal Sadaqat; Gate-users at lists.opengatecollaboration.org
Betreff: Re: [Gate-users] execution of a file

Greetings,

Did you try the suggestion that was given to you last time(26 Jan. 2020) you asked [1]? If yes, was there any problem?

Have a nice day,
Maxime Toussaint

[1] http://lists.opengatecollaboration.org/pipermail/gate-users/2020-January/011278.html
________________________________
De : Gate-users <gate-users-bounces at lists.opengatecollaboration.org> de la part de Muhammad Afzaal Sadaqat <muhammadafzaalsadaqat786 at gmail.com>
Envoyé : 3 mai 2020 23:15
À : Gate-users at lists.opengatecollaboration.org <Gate-users at lists.opengatecollaboration.org>
Objet : [Gate-users] execution of a file

Hello, hope you are doing well!
I have installed gate-8.2 in ubuntu 19.10. I am following this link to execute a file
https://smallbusiness.chron.com/execute-file-macbook-terminal-49381.html<https://can01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fsmallbusiness.chron.com%2Fexecute-file-macbook-terminal-49381.html&data=02%7C01%7Cmaxime.toussaint%40usherbrooke.ca%7C8c350b2225474c3de5b508d7efd971db%7C3a5a8744593545f99423b32c3a5de082%7C0%7C0%7C637241589517518031&sdata=sUjqnApJOtJTGvyS2NNJmFElOvR%2F%2ByCaLRW2yREQHfc%3D&reserved=0>
but i am getting error at the end. I copied the full text below. Need your suggestions to resolve this.
Thanks
afzaal at afzaal-HP-Laptop-15-bw0xx:~$ cd /home/afzaal/Gate-8.2/benchmarks/benchImaging/mac/
afzaal at afzaal-HP-Laptop-15-bw0xx:~/Gate-8.2/benchmarks/benchImaging/mac$ chmod +x ./optical.mac
afzaal at afzaal-HP-Laptop-15-bw0xx:~/Gate-8.2/benchmarks/benchImaging/mac$ ./optical.mac
./optical.mac: line 1: /control/execute: No such file or directory
./optical.mac: line 7: /gate/geometry/setMaterialDatabase: No such file or directory
./optical.mac: line 10: /gate/world/geometry/setXLength: No such file or directory
./optical.mac: line 11: /gate/world/geometry/setYLength: No such file or directory
./optical.mac: line 12: /gate/world/geometry/setZLength: No such file or directory
./optical.mac: line 13: /gate/world/setMaterial: No such file or directory
./optical.mac: line 14: /gate/world/vis/forceWireframe: No such file or directory
./optical.mac: line 15: /gate/world/vis/setColor: No such file or directory
./optical.mac: line 18: /gate/world/daughters/name: No such file or directory
./optical.mac: line 19: /gate/world/daughters/insert: No such file or directory
./optical.mac: line 20: /gate/OpticalSystem/geometry/setXLength: No such file or directory
./optical.mac: line 21: /gate/OpticalSystem/geometry/setYLength: No such file or directory
./optical.mac: line 22: /gate/OpticalSystem/geometry/setZLength: No such file or directory
./optical.mac: line 23: /gate/OpticalSystem/placement/setTranslation: No such file or directory
./optical.mac: line 24: /gate/OpticalSystem/setMaterial: No such file or directory
./optical.mac: line 25: /gate/OpticalSystem/vis/setColor: No such file or directory
./optical.mac: line 26: /gate/OpticalSystem/vis/forceWireframe: No such file or directory
./optical.mac: line 29: /gate/OpticalSystem/daughters/name: No such file or directory
./optical.mac: line 30: /gate/OpticalSystem/daughters/insert: No such file or directory
./optical.mac: line 31: /gate/detector/geometry/setXLength: No such file or directory
./optical.mac: line 32: /gate/detector/geometry/setYLength: No such file or directory
./optical.mac: line 33: /gate/detector/geometry/setZLength: No such file or directory
./optical.mac: line 34: /gate/detector/placement/setTranslation: No such file or directory
./optical.mac: line 35: /gate/detector/setMaterial: No such file or directory
./optical.mac: line 36: /gate/detector/vis/setColor: No such file or directory
./optical.mac: line 37: /gate/detector/vis/forceSolid: No such file or directory
./optical.mac: line 40: /gate/OpticalSystem/daughters/name: No such file or directory
./optical.mac: line 41: /gate/OpticalSystem/daughters/insert: No such file or directory
./optical.mac: line 42: /gate/Electronics/geometry/setXLength: No such file or directory
./optical.mac: line 43: /gate/Electronics/geometry/setYLength: No such file or directory
./optical.mac: line 44: /gate/Electronics/geometry/setZLength: No such file or directory
./optical.mac: line 45: /gate/Electronics/placement/setTranslation: No such file or directory
./optical.mac: line 46: /gate/Electronics/setMaterial: No such file or directory
./optical.mac: line 47: /gate/Electronics/vis/setColor: No such file or directory
./optical.mac: line 48: /gate/Electronics/vis/forceSolid: No such file or directory
./optical.mac: line 50: /gate/systems/OpticalSystem/crystal/attach: No such file or directory
./optical.mac: line 52: /gate/detector/attachCrystalSD: No such file or directory
./optical.mac: line 55: /gate/world/daughters/name: No such file or directory
./optical.mac: line 56: /gate/world/daughters/insert: No such file or directory
./optical.mac: line 57: /gate/waterBox/geometry/setXLength: No such file or directory
./optical.mac: line 58: /gate/waterBox/geometry/setYLength: No such file or directory
./optical.mac: line 59: /gate/waterBox/geometry/setZLength: No such file or directory
./optical.mac: line 60: /gate/waterBox/setMaterial: No such file or directory
./optical.mac: line 61: /gate/waterBox/placement/setTranslation: No such file or directory
./optical.mac: line 62: /gate/waterBox/vis/setColor: No such file or directory
./optical.mac: line 63: /gate/waterBox/vis/forceSolid: No such file or directory
./optical.mac: line 65: /gate/waterBox/attachPhantomSD: No such file or directory
./optical.mac: line 71: /gate/physics/addProcess: No such file or directory
./optical.mac: line 72: /gate/physics/addProcess: No such file or directory
./optical.mac: line 73: /gate/physics/addProcess: No such file or directory
./optical.mac: line 74: /gate/physics/addProcess: No such file or directory
./optical.mac: line 75: /gate/physics/addProcess: No such file or directory
./optical.mac: line 76: /gate/physics/processList: No such file or directory
./optical.mac: line 77: /gate/physics/processList: No such file or directory
./optical.mac: line 83: /gate/actor/addActor: No such file or directory
./optical.mac: line 84: /gate/actor/stat/save: No such file or directory
./optical.mac: line 90: /gate/run/initialize: No such file or directory
./optical.mac: line 93: /gate/detector/surfaces/name: No such file or directory
./optical.mac: line 94: /gate/detector/surfaces/insert: No such file or directory
./optical.mac: line 95: /gate/detector/surfaces/Detection1/setSurface: No such file or directory
./optical.mac: line 96: /gate/Electronics/surfaces/name: No such file or directory
./optical.mac: line 97: /gate/Electronics/surfaces/insert: No such file or directory
./optical.mac: line 98: /gate/Electronics/surfaces/Detection2/setSurface: No such file or directory
./optical.mac: line 104: /gate/digitizer/Singles/insert: No such file or directory
./optical.mac: line 105: /gate/digitizer/Singles/insert: No such file or directory
./optical.mac: line 106: /gate/digitizer/Singles/readout/setDepth: No such file or directory
./optical.mac: line 113: /gate/source/addSource: No such file or directory
./optical.mac: line 114: /gate/source/Mysource/gps/particle: No such file or directory
./optical.mac: line 115: /gate/source/Mysource/gps/monoenergy: No such file or directory
./optical.mac: line 116: /gate/source/Mysource/gps/energytype: No such file or directory
./optical.mac: line 117: /gate/source/Mysource/setActivity: No such file or directory
./optical.mac: line 118: /gate/source/Mysource/gps/polarization: No such file or directory
./optical.mac: line 119: /gate/source/Mysource/gps/type: No such file or directory
./optical.mac: line 120: /gate/source/Mysource/gps/shape: No such file or directory
./optical.mac: line 121: /gate/source/Mysource/gps/radius: No such file or directory
./optical.mac: line 122: /gate/source/Mysource/gps/centre: No such file or directory
./optical.mac: line 123: /gate/source/Mysource/gps/direction: No such file or directory
./optical.mac: line 137: /gate/output/root/enable: No such file or directory
./optical.mac: line 138: /gate/output/root/setFileName: No such file or directory
./optical.mac: line 139: /gate/output/root/setRootHitFlag: No such file or directory
./optical.mac: line 140: /gate/output/root/setRootSinglesFlag: No such file or directory
./optical.mac: line 141: /gate/output/root/setRootOpticalFlag: No such file or directory
./optical.mac: line 144: /gate/output/projection/enable: No such file or directory
./optical.mac: line 145: /gate/output/projection/setFileName: No such file or directory
./optical.mac: line 146: /gate/output/projection/projectionPlane: No such file or directory
./optical.mac: line 147: /gate/output/projection/pixelNumberX: No such file or directory
./optical.mac: line 148: /gate/output/projection/pixelNumberY: No such file or directory
./optical.mac: line 149: /gate/output/projection/pixelSizeX: No such file or directory
./optical.mac: line 150: /gate/output/projection/pixelSizeY: No such file or directory
./optical.mac: line 157: /gate/random/setEngineName: No such file or directory
./optical.mac: line 158: /gate/random/setEngineSeed: No such file or directory
./optical.mac: line 160: /gate/application/setTimeSlice: No such file or directory
./optical.mac: line 161: /gate/application/setTimeStart: No such file or directory
./optical.mac: line 162: /gate/application/setTimeStop: No such file or directory
./optical.mac: line 163: /gate/application/startDAQ: No such file or directory
afzaal at afzaal-HP-Laptop-15-bw0xx:~/Gate-8.2/benchmarks/benchImaging/mac$
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opengatecollaboration.org/pipermail/gate-users/attachments/20200507/4e1beec5/attachment-0001.html>


More information about the Gate-users mailing list