<?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 Re: run python script in python window in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233711#M8042</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Typically you'd set it up to behave like a module:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def mainfunc(a, b):
&amp;nbsp; return do_some_stuff(a, b)

if __name__ == "__main__":
&amp;nbsp; import sys
&amp;nbsp; mainfunc(sys.argv[1], sys.argv[2])&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then you can call mainfunc(a, b) in the Python window once you've loaded it in. The interactive console's environment is slightly different than running a standalone script, just like in any other Python prompt (Pythonwin, Idle, etc).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 11:49:14 GMT</pubDate>
    <dc:creator>JasonScheirer</dc:creator>
    <dc:date>2021-12-11T11:49:14Z</dc:date>
    <item>
      <title>run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233707#M8038</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This seems absurdly simple to ask, but I cannot seem to find the answer, and I've scoured the help files.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a script (let's say it's called myscript.py) and requires 2 arguments.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How the heck do I execute that script from within the python window in ArcGIS 10?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;execfile() seems close, but I can't figure out how to pass the arguments.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 14:55:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233707#M8038</guid>
      <dc:creator>MikeTischler</dc:creator>
      <dc:date>2010-08-11T14:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233708#M8039</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I haven't messed with it much, but I don't think there is a way of passing arguments to a script when you execute it via the python window! If I am right, ESRI must have overlooked this one. I think your options would then be to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Hard code the arguments in the script, and run it via the python window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. If your arguments are simple, like a&amp;nbsp; single number or something, use the input() method. Example: test = input("Provide a number")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. Run the script in Pythonwin, wing, etc. where you can specify the parameters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. Build a toolbox and use arcpy.getparameterastext() in you code to accept the arguments from the toolbox.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 16:09:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233708#M8039</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-08-11T16:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233709#M8040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Chris,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Those workarounds do just fine - but it seems silly to have to do those.&amp;nbsp; Isn't passing arguments a very, very basic functionality?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 16:10:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233709#M8040</guid>
      <dc:creator>MikeTischler</dc:creator>
      <dc:date>2010-08-11T16:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233710#M8041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You would think...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 16:13:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233710#M8041</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-08-11T16:13:03Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233711#M8042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Typically you'd set it up to behave like a module:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def mainfunc(a, b):
&amp;nbsp; return do_some_stuff(a, b)

if __name__ == "__main__":
&amp;nbsp; import sys
&amp;nbsp; mainfunc(sys.argv[1], sys.argv[2])&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then you can call mainfunc(a, b) in the Python window once you've loaded it in. The interactive console's environment is slightly different than running a standalone script, just like in any other Python prompt (Pythonwin, Idle, etc).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:49:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233711#M8042</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-11T11:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233712#M8043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;But how do you specify values for sys.argv[whatever] via the Python window in ArcMap? It seems as if you can't...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 18:44:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233712#M8043</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-08-11T18:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233713#M8044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;But through what dialog in the Python window can a users specify values for sys.argv[whataver]?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; def func(a,b):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(a) + " - " + str(b)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;... &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; func(1,2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1 - 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; import sys&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; func(sys.argv[1],sys.argv[2])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Runtime error &amp;lt;type 'exceptions.IndexError'&amp;gt;: list index out of range&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 18:51:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233713#M8044</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-08-11T18:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233714#M8045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You would do something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;a = "c:\\data\\my.gdb\\featureclass"
b = 5
func(a, b)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;No need to get sys.argv involved.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:49:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233714#M8045</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-11T11:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233715#M8046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;and what is the syntax for calling a .py script ?&amp;nbsp; I can't just type the name of the python file into the command line.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 19:17:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233715#M8046</guid>
      <dc:creator>MikeTischler</dc:creator>
      <dc:date>2010-08-11T19:17:20Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233716#M8047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;and what is the syntax for calling a .py script ?&amp;nbsp; I can't just type the name of the python file into the command line.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have used methods like os.execl, etc. (see more on &lt;/SPAN&gt;&lt;A href="http://docs.python.org/library/os.html"&gt;http://docs.python.org/library/os.html&lt;/A&gt;&lt;SPAN&gt;) to call a file directly (including .py's) with varying levels of success.&amp;nbsp; But that's not going to run in process or anything, and passing in arguments like a layer in your current map isn't going to work.&amp;nbsp; Jason's approach will be the cleanest way to do it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Dave&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 19:28:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233716#M8047</guid>
      <dc:creator>DavidWynne</dc:creator>
      <dc:date>2010-08-11T19:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233717#M8048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think Michael's original question was that if he has a script like so:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import sys&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;x = sys.argv[1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;y = sys.argv[2]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print x + y&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How can the script be executed in the ArcGIS Python Window so that a user can specify the arguments for x and y? There doesn't seem to be a way for the python window to accept user input using the standard sys.argv[] method (like via Pythonwin)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Correct me if I am wrong, but it seems like the Python window is basically just an interactive window (not a full blown IDE), and not really geared for running a full script in (just one line at a time).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 19:39:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233717#M8048</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2010-08-11T19:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233718#M8049</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's one approach:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Run the script from ARC 10 like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; os.system("myscript.py&amp;nbsp; Hi&amp;nbsp; Mom")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;myscript.py looks like this and will write the 2 arguments to log.txt:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import sys
one = sys.argv[1]
two = sys.argv[2]
message = open("c:/temp/log.txt", "a")
message.write(one+"\n")
message.write(two+"\n")
&lt;/PRE&gt;&lt;SPAN&gt;** If you want to run python scripts (on a regular basis) from the command line though, it's easier to just pull up a windows command prompt and run it from there.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If your system is set up right, for the command prompt, you can simply do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt; myscript&amp;nbsp; Hi&amp;nbsp; Mom&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:49:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233718#M8049</guid>
      <dc:creator>RDHarles</dc:creator>
      <dc:date>2021-12-11T11:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233719#M8050</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I think Charles has a way of running that script 'as is'.&amp;nbsp; Although for the original case, the arguments will be coming in as strings, so if the inputs are 1 and 2, the answer will be 12 (adding "1" to "2") vs 3--which could be accomplished by something like x = int(sys.argv[1])&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Correct me if I am wrong, but it seems like the Python window is basically just an interactive window (not a full blown IDE), and not really geared for running a full script in (just one line at a time).&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It's all about how you organize your code.&amp;nbsp; The more 'pythonic' way would be to organize the code into function(s), which is very easy to just call, and without having to run the script as a file.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Dave&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Aug 2010 20:37:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233719#M8050</guid>
      <dc:creator>DavidWynne</dc:creator>
      <dc:date>2010-08-11T20:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233720#M8051</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Charles' solution works for me - at least for this particular problem.&amp;nbsp; I'm moving from VBA/.NET ArcObjects into python, so it'll take me a while to be "pythonic".&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks guys,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mike&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Aug 2010 11:38:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233720#M8051</guid>
      <dc:creator>MikeTischler</dc:creator>
      <dc:date>2010-08-12T11:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233721#M8052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi all,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm just wondering if there's been some update on this problem yet.&amp;nbsp; sys.argv won't work.&amp;nbsp;&amp;nbsp; I tried using&amp;nbsp; SetParameterAsText and GetParameterAsText together too.&amp;nbsp; That didn't work.&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Mar 2012 15:30:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233721#M8052</guid>
      <dc:creator>LT</dc:creator>
      <dc:date>2012-03-28T15:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233722#M8053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I just wanted to update this thread with a test I ran today in ArcMap 10.2, attempting to use GetParameterAsText.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I first made an empty text file in my temp folder, c:\temp\log.txt (no programming, just went in and made the text file.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the script I used to test, it builds off the one shown earlier/above in this discussion.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import sys&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#one = sys.argv[1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#two = sys.argv[2]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;one = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;two = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;message = open("c:/temp/log.txt", "a")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;message.write(one+"\n")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;message.write(two+"\n")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is what I did in the Python Window in ArcMap, it ran and returned exit code 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; os.system("c:\student\script1.py hi mom")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here are the contents of the output text file, log.txt.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mom&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Nov 2013 19:58:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233722#M8053</guid>
      <dc:creator>RobertBurke</dc:creator>
      <dc:date>2013-11-15T19:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: run python script in python window</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233723#M8054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the helpful update, Robert!&lt;/P&gt;&lt;P&gt;If you were planning on executing the script from Windows Task Scheduler, would you move the comments hash from the sys.argv variables and put them in front of the arcpy.GetParameterAsText variables in your script, or are you just explaining where those variable will receive their arguments from?&lt;/P&gt;&lt;P&gt;In other words, do we need to use sys.argv for Scheduled Tasks?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Sep 2019 21:07:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-python-script-in-python-window/m-p/233723#M8054</guid>
      <dc:creator>JoeBryant1</dc:creator>
      <dc:date>2019-09-04T21:07:18Z</dc:date>
    </item>
  </channel>
</rss>

