<?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: Read Data into Bat File from Txt File to Be Used As Variables in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435841#M34238</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; As I said in the original Post, I need to add the full path to the python script and log files in the bat file on a Windows 2008 Server which I did not need to do in Windows 2003 Server.&amp;nbsp; &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So Win 2008 Server isn't allowing you to set a "Start in:" folder?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another approach to run python scripts no matter where they are is add a folder containing your python scripts to the Windows PATH variable. You can do this just inside your .bat script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your .bat script can also use pushd to change the current folder after the script starts.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Or is there another method of calling the python files that can be used?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was suggesting using Python (os.system(), subprocess, etc)...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm still a bit confused as to what the problem is.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Mar 2012 14:23:26 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2012-03-07T14:23:26Z</dc:date>
    <item>
      <title>Read Data into Bat File from Txt File to Be Used As Variables</title>
      <link>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435836#M34233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;To All Python Users That Use Bat Files to Call Python Scripts:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to read in values from a txt file in a bat file that will be used as variables when calling python scripts within the bat file.&amp;nbsp; I have searched the Internet for the proper syntax to accomplish this goal, but I am unable to read from a txt file in the bat file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone have experience with this task and could provide some sample code so I can see where I am going wrong?&amp;nbsp; Any help or hints are greatly appreciated.&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 16:14:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435836#M34233</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-03-02T16:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Read Data into Bat File from Txt File to Be Used As Variables</title>
      <link>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435837#M34234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;To All Python Users That Use Bat Files to Call Python Scripts:&lt;BR /&gt;&lt;BR /&gt;I am trying to read in values from a txt file in a bat file that will be used as variables when calling python scripts within the bat file.&amp;nbsp; I have searched the Internet for the proper syntax to accomplish this goal, but I am unable to read from a txt file in the bat file.&lt;BR /&gt;&lt;BR /&gt;Does anyone have experience with this task and could provide some sample code so I can see where I am going wrong?&amp;nbsp; Any help or hints are greatly appreciated.&amp;nbsp; Thanks.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;One approach you could try is to read file directly in python script so you don't have to pass variables from bat file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Mar 2012 19:54:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435837#M34234</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2012-03-02T19:54:14Z</dc:date>
    </item>
    <item>
      <title>Re: Read Data into Bat File from Txt File to Be Used As Variables</title>
      <link>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435838#M34235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Presumably you could use I/O redirection to do this -- but I think it would a lot easier to write the driver script in Python instead of the arguably primitive Windows command shell. (Not to knock it - the good old cmd.exe still has its place.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;If your python scripts are set up to only work with command line arguments, you can run them with os.system() or (better) the &lt;A href="&amp;lt;/span&amp;gt;&amp;lt;a" target="_blank"&gt;newer" rel="nofollow" target="_blank"&amp;gt;http://docs.python.org/library/subprocess.html#module-subprocess]newer&lt;/A&gt;&lt;SPAN&gt; subprocess module.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2012 14:12:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435838#M34235</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-03-03T14:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: Read Data into Bat File from Txt File to Be Used As Variables</title>
      <link>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435839#M34236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Curtis:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think my original post might be a bit misleading.&amp;nbsp; The variables I am trying to pass into the bat file are the location of the the python script and the location of the log file generated from the bat file.&amp;nbsp; When I ran bat files as Scheduled Tasks in Windows Server 2003, I only needed to provide the name of the python script and log file because it understood it was a path relative to the location of the bat file.&amp;nbsp; Now on Windows Server 2008, the bat file never calls the python script or log file unless I supply the entire path to these files.&amp;nbsp; I want to store these paths in a text file to simplify the update of my system and the scripts that are used.&amp;nbsp; I have 2 reasons for this.&amp;nbsp; I can have multiple scripts that need the same python scripts, so I can use the text file to supply this information to all bat files.&amp;nbsp; In addition, if the location changes or this bat file is used on a different server, I only need to make the change in the text file and not each bat file.&amp;nbsp; I hope this clears up why I want to be able to read in information from a txt file in a bat file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Mar 2012 17:11:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435839#M34236</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-03-03T17:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Read Data into Bat File from Txt File to Be Used As Variables</title>
      <link>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435840#M34237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does anyone from ESRI have any ideas on how I would accomplish this goal in a bat file?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or is there another method of calling the python files that can be used?&amp;nbsp; I currently use the bat file to sequentially call python scripts so they proceed in a specific order making sure the previous task has been completed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As I said in the original Post, I need to add the full path to the python script and log files in the bat file on a Windows 2008 Server which I did not need to do in Windows 2003 Server.&amp;nbsp; Also I would like to use the txt file for the paths so it acts as a config file to be used by multiple scripts so 1 file can be changed for multiple scripts instead of needing to change multiple files.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2012 11:46:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435840#M34237</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-03-07T11:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Read Data into Bat File from Txt File to Be Used As Variables</title>
      <link>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435841#M34238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; As I said in the original Post, I need to add the full path to the python script and log files in the bat file on a Windows 2008 Server which I did not need to do in Windows 2003 Server.&amp;nbsp; &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So Win 2008 Server isn't allowing you to set a "Start in:" folder?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another approach to run python scripts no matter where they are is add a folder containing your python scripts to the Windows PATH variable. You can do this just inside your .bat script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your .bat script can also use pushd to change the current folder after the script starts.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Or is there another method of calling the python files that can be used?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was suggesting using Python (os.system(), subprocess, etc)...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm still a bit confused as to what the problem is.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Mar 2012 14:23:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/read-data-into-bat-file-from-txt-file-to-be-used/m-p/435841#M34238</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-03-07T14:23:26Z</dc:date>
    </item>
  </channel>
</rss>

