<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Run external program in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/run-external-program/m-p/396575#M31300</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I try to run a external program from within arcmap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wherefore I made a model with the model builder. So I can select a point in my shape, run my model and the external program should run with a variable from this point. To start the program I use a simple python script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To explain my problem, I have included the following line of code with which I started. If I uses this, the script does nothing, no error and no execution of anything:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14413686321355298" data-renderedposition="184_8_895_16" jivemacro_uid="_14413686321355298"&gt;&lt;P&gt;os.system(r'C:\Program Files (x86)\AquaInfo\AI-Viewer.exe SystemMDW=C:\Program Files (x86)\AquaInfo\Aqua.mdw|UserMDB=C:\Program Files (x86)\AquaInfo\System\AI_mbn.mdb|DataBaseName=C:\Users\ps\Desktop\atest\Test.mdb|UserId=99999998|ObjIdsList=7297|SelObjId=7297|ObjType= 0|')&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I put this into windows cmd the program starts:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39; font-size: 12pt;"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/SPAN&gt;C:\Program Files (x86)\AquaInfo\AI-Viewer.exe&lt;SPAN style="color: #e23d39; font-size: 12pt;"&gt;&lt;STRONG&gt;" "&lt;/STRONG&gt;&lt;/SPAN&gt;SystemMDW=C:\Program Files (x86)\AquaInfo\Aqua.mdw|UserMDB=C:\Program Files (x86)\AquaInfo\System\AI_mbn.mdb|DataBaseName=C:\Users\ps\Desktop\atest\Test.mdb|UserId=99999998|ObjIdsList=7297|SelObjId=7297|ObjType= 0|&lt;SPAN style="color: #e23d39; font-size: 12pt;"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030;"&gt;If I am using this python code in my module, the program starts with an error because obviously some variables are not set:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14413686420217009 jive_text_macro" data-renderedposition="395_8_895_16" jivemacro_uid="_14413686420217009"&gt;&lt;SPAN style="color: #303030;"&gt;os.system(r'"C:\Program Files (x86)\AquaInfo\AI-Viewer.exe"')&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030;"&gt;Same if I try this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14413686543495698 jive_text_macro" data-renderedposition="474_8_895_16" jivemacro_uid="_14413686543495698"&gt;&lt;SPAN style="color: #303030;"&gt;os.system(r'"C:\Program Files (x86)\AquaInfo\AI-Viewer.exe"' + " SystemMDW=C:\Program Files (x86)\AquaInfo\Aqua.mdw") &lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As soon as I enter the Pipe Character "|" the script doesn't work any more. I tried to replace "|" with chr(124) but still the same error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14413686655763800" data-renderedposition="553_8_895_16" jivemacro_uid="_14413686655763800"&gt;&lt;P&gt;os.system(r'"C:\Program Files (x86)\AquaInfo\AI-Viewer.exe"' + " SystemMDW=C:\Program Files (x86)\AquaInfo\Aqua.mdw|")&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not very firm with python, I am more experienced in vbs. Is there a problem with the "|" Character in Python Strings then it is used for a path with os.system?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I solve this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Sep 2015 12:03:36 GMT</pubDate>
    <dc:creator>PSArcOnlinePSArcOnline</dc:creator>
    <dc:date>2015-09-04T12:03:36Z</dc:date>
    <item>
      <title>Run external program</title>
      <link>https://community.esri.com/t5/python-questions/run-external-program/m-p/396575#M31300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I try to run a external program from within arcmap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wherefore I made a model with the model builder. So I can select a point in my shape, run my model and the external program should run with a variable from this point. To start the program I use a simple python script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To explain my problem, I have included the following line of code with which I started. If I uses this, the script does nothing, no error and no execution of anything:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14413686321355298" data-renderedposition="184_8_895_16" jivemacro_uid="_14413686321355298"&gt;&lt;P&gt;os.system(r'C:\Program Files (x86)\AquaInfo\AI-Viewer.exe SystemMDW=C:\Program Files (x86)\AquaInfo\Aqua.mdw|UserMDB=C:\Program Files (x86)\AquaInfo\System\AI_mbn.mdb|DataBaseName=C:\Users\ps\Desktop\atest\Test.mdb|UserId=99999998|ObjIdsList=7297|SelObjId=7297|ObjType= 0|')&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I put this into windows cmd the program starts:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39; font-size: 12pt;"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/SPAN&gt;C:\Program Files (x86)\AquaInfo\AI-Viewer.exe&lt;SPAN style="color: #e23d39; font-size: 12pt;"&gt;&lt;STRONG&gt;" "&lt;/STRONG&gt;&lt;/SPAN&gt;SystemMDW=C:\Program Files (x86)\AquaInfo\Aqua.mdw|UserMDB=C:\Program Files (x86)\AquaInfo\System\AI_mbn.mdb|DataBaseName=C:\Users\ps\Desktop\atest\Test.mdb|UserId=99999998|ObjIdsList=7297|SelObjId=7297|ObjType= 0|&lt;SPAN style="color: #e23d39; font-size: 12pt;"&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030;"&gt;If I am using this python code in my module, the program starts with an error because obviously some variables are not set:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14413686420217009 jive_text_macro" data-renderedposition="395_8_895_16" jivemacro_uid="_14413686420217009"&gt;&lt;SPAN style="color: #303030;"&gt;os.system(r'"C:\Program Files (x86)\AquaInfo\AI-Viewer.exe"')&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030;"&gt;Same if I try this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14413686543495698 jive_text_macro" data-renderedposition="474_8_895_16" jivemacro_uid="_14413686543495698"&gt;&lt;SPAN style="color: #303030;"&gt;os.system(r'"C:\Program Files (x86)\AquaInfo\AI-Viewer.exe"' + " SystemMDW=C:\Program Files (x86)\AquaInfo\Aqua.mdw") &lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As soon as I enter the Pipe Character "|" the script doesn't work any more. I tried to replace "|" with chr(124) but still the same error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14413686655763800" data-renderedposition="553_8_895_16" jivemacro_uid="_14413686655763800"&gt;&lt;P&gt;os.system(r'"C:\Program Files (x86)\AquaInfo\AI-Viewer.exe"' + " SystemMDW=C:\Program Files (x86)\AquaInfo\Aqua.mdw|")&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not very firm with python, I am more experienced in vbs. Is there a problem with the "|" Character in Python Strings then it is used for a path with os.system?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I solve this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Sep 2015 12:03:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-external-program/m-p/396575#M31300</guid>
      <dc:creator>PSArcOnlinePSArcOnline</dc:creator>
      <dc:date>2015-09-04T12:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Run external program</title>
      <link>https://community.esri.com/t5/python-questions/run-external-program/m-p/396576#M31301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The reason that the pipe character is special, is on UNIX based operating systems, it's used to denote steps in &lt;A href="https://en.wikipedia.org/wiki/Pipeline_%28Unix%29" rel="nofollow noopener noreferrer" target="_blank"&gt;a pipeline&lt;/A&gt;, and is handled specially. In your case this isn't what you want, I'd recommend using the subprocess module instead of os.system:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import subprocess
subprocess.call([r&lt;SPAN class="string"&gt;'C:\Program Files (x86)\AquaInfo\AI-Viewer.exe',&lt;/SPAN&gt;
&lt;SPAN class="string"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r'SystemMDW=C:\Program Files (x86)\AquaInfo\Aqua.mdw|UserMDB=C:\Program Files (x86)\AquaInfo\System\AI_mbn.mdb|DataBaseName=C:\Users\ps\Desktop\atest\Test.mdb|UserId=99999998|ObjIdsList=7297|SelObjId=7297|ObjType= 0|'])&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;I don't have the AquaInfo software to test against, but in an example script, that passed the arguments correctly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="string"&gt;Shaun&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:08:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-external-program/m-p/396576#M31301</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2021-12-11T18:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Run external program</title>
      <link>https://community.esri.com/t5/python-questions/run-external-program/m-p/396577#M31302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had something "similar", trying to pass values to the external gpg.exe program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is how I resolved it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;TheCommand = "gpg.exe --homedir ./Dependencies --passphrase MyPassword --output C:/crashdata/" + fname.replace('.ASC','.CSV') +" --decrypt " + fname
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
os.system(TheCommand)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically, I keep trying the string concatenation in IDLE (or your favorite interpreter) until the string looks exactly like I need it (all pipes, tags, etc.) then os.system on the variable containing the string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I see Shaun posted while I was typing.&amp;nbsp; I think the subprocess.call would be the "proper" way, but with my gpg.exe one, I could not get the subprocess to work, no matter how I tried.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:08:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-external-program/m-p/396577#M31302</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2021-12-11T18:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Run external program</title>
      <link>https://community.esri.com/t5/python-questions/run-external-program/m-p/396578#M31303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN class="hps"&gt;Thank you both&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;for the help&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;subprocess did the trick.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN class="hps"&gt;And thanks for&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the&lt;/SPAN&gt; &lt;SPAN class="hps atn"&gt;"&lt;/SPAN&gt;&lt;SPAN&gt;Pipe&lt;/SPAN&gt;&lt;SPAN&gt;"&lt;/SPAN&gt; explanation. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Sep 2015 06:01:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/run-external-program/m-p/396578#M31303</guid>
      <dc:creator>PSArcOnlinePSArcOnline</dc:creator>
      <dc:date>2015-09-10T06:01:18Z</dc:date>
    </item>
  </channel>
</rss>

