# Run executables via SWAN notebook?

**URL:** <https://swan-community.web.cern.ch/t/run-executables-via-swan-notebook/394>\
**Category:** Software\
**Created:** [March 24, 2021, 6:46pm UTC](https://swan-community.web.cern.ch/t/run-executables-via-swan-notebook/394 "2021-03-24T18:46:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![emm](https://swan-community.web.cern.ch/letter_avatar_proxy/v4/letter/e/71c47a/32.png) [@emm](https://swan-community.web.cern.ch/u/emm)\
**Post date:** [March 24, 2021, 6:46pm UTC](https://swan-community.web.cern.ch/t/run-executables-via-swan-notebook/394/1 "2021-03-24T18:46:11Z")

</div>

Hello,  
Is it possible to run an executable present on the CERNBox via a SWAN notebook? In a Python script, this is easy to implement.  
For example, let’s imagine one has a cool\_app.exe executable in the CERNBox; the app is not written in python so it cannot easily be translated into a python package.  
It’d be really cool if one could run it from a SWAN notebook with a command like  
subprocess.Popen(cool\_app.exe)  
Possible? Foreseen?  
Thank you in advance for your help,  
Emmanuele

---

<div class="post-metadata">

**Author:** ![vbrian](https://swan-community.web.cern.ch/user_avatar/swan-community.web.cern.ch/vbrian/32/22_2.png) [@vbrian](https://swan-community.web.cern.ch/u/vbrian)\
**Post date:** [April 5, 2021, 8:55am UTC](https://swan-community.web.cern.ch/t/run-executables-via-swan-notebook/394/2 "2021-04-05T08:55:01Z")

</div>

Dear Emmanuelle,

I think this is already possible since the subprocess module is available through SWAN. For instance using r = subprocess.run( [“path\_to\_executable”,“argument”], capture\_output=True) or something like that, seems to work for me…  
However you have to be careful of your environment if your executable depends on dynamic libraries, namely the LD\_LIBRARY\_PATH. You have to make sure to have everything in the LD\_LIBRARY\_PATH in your SWAN session, which can be set through an environment script at the configuration step. (or direclty in a notebook or the SWAN console). From this I guess all the ingredients are there…

Moreover, you may know that there is a powerful way to run c++ code in SWAN using the ROOT software and the ROOT bindings such as this example  
[https://swan-gallery.web.cern.ch/notebooks/basic/notebooks/CppFromPython\_pycpp.html](https://swan-gallery.web.cern.ch/notebooks/basic/notebooks/CppFromPython_pycpp.html)  
The very interesting from this is to get some compatible output from your c++ code, such as objects, directly in python through ROOT, and this is great for interactivity with the c++ code.  
However this needs a dynamic library (.so) file from your c++ code, meaning that you need to adapt the makefile to create such library, to be loaded in root as you see in the example. Side remark, you may have some warnings in swan if you compiled the code with a different gcc version, but anyway… I hope this helps !

Happy Easter, and cheers !  
Brian

---

<div class="post-metadata">

**Author:** ![emm](https://swan-community.web.cern.ch/letter_avatar_proxy/v4/letter/e/71c47a/32.png) [@emm](https://swan-community.web.cern.ch/u/emm)\
**Post date:** [April 11, 2021, 12:38pm UTC](https://swan-community.web.cern.ch/t/run-executables-via-swan-notebook/394/3 "2021-04-11T12:38:59Z")

</div>

Thank you for the reply, and Happy Easter.  
Is there a small guide explaining how to view/edit the LD\_LIBRARY\_PATH ? I’m not familiar with this variable.

When trying to run the code line you kindly proposed, including the path to the .exe file in SWAN, I obtain the error:  
`[Errno 8] Exec format error: '/eos/home-e/my_username/SWAN_projects/tests/my_folder/my_app.exe'`  
In my specific case, which is probably not the most general case, I’m trying to run an executable that was generated with Matlab, and hence requires the Matlab Runtime (MCR) software. This is probably why I obtain the error message.  
Do you see any workaround?

---

<div class="post-metadata">

**Author:** ![dalvesde](https://swan-community.web.cern.ch/letter_avatar_proxy/v4/letter/d/db5fbb/32.png) [@dalvesde](https://swan-community.web.cern.ch/u/dalvesde)\
**Post date:** [April 12, 2021, 3:42pm UTC](https://swan-community.web.cern.ch/t/run-executables-via-swan-notebook/394/4 "2021-04-12T15:42:57Z")

</div>

Hi Emmanuele,  
Since you mention .exe files, I assume you’re trying to run a Windows executable. Your SWAN session runs on a Centos 7 (CC7) container, so you won’t be able to run windows software there.  
Cheers,  
Diogo

---

<div class="post-metadata">

**Author:** ![emm](https://swan-community.web.cern.ch/letter_avatar_proxy/v4/letter/e/71c47a/32.png) [@emm](https://swan-community.web.cern.ch/u/emm)\
**Post date:** [April 12, 2021, 4:03pm UTC](https://swan-community.web.cern.ch/t/run-executables-via-swan-notebook/394/5 "2021-04-12T16:03:56Z")

</div>

Thank you Diogo.  
Yes, I’m trying to run an executable that I regularly use in my Windows machine.  
Isn’t there any workaround?  
What application types are supported?  
Cheers
