# how to run the python script from ansible to Windows 2019?

**URL:** <https://forum.ansible.com/t/how-to-run-the-python-script-from-ansible-to-windows-2019/32884>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [May 8, 2020, 6:55am UTC](https://forum.ansible.com/t/how-to-run-the-python-script-from-ansible-to-windows-2019/32884 "2020-05-08T06:55:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhilipsingh\_G](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@Dhilipsingh\_G](https://forum.ansible.com/u/Dhilipsingh_G)\
**Post date:** [May 8, 2020, 6:55am UTC](https://forum.ansible.com/t/how-to-run-the-python-script-from-ansible-to-windows-2019/32884/1 "2020-05-08T06:55:03Z")

</div>

hi Team ,

i am getting error while run the python script from ansible to windows 2019. kindly help me to fix the issue

error :

“Traceback (most recent call last):”,  
" File "deploy.py", line 866, in “,  
" DatabaseCreator().main()”,  
" File "deploy.py", line 788, in main",  
" os.makedirs(self.ECRF\_FGDB\_PATH)“,  
" File "F:\Python27\ArcGISx6410.7\lib\os.py", line 150, in makedirs”,  
" makedirs(head, mode)“,  
" File "F:\Python27\ArcGISx6410.7\lib\os.py", line 150, in makedirs”,  
" makedirs(head, mode)“,  
" File "F:\Python27\ArcGISx6410.7\lib\os.py", line 150, in makedirs”,  
" makedirs(head, mode)“,  
" File "F:\Python27\ArcGISx6410.7\lib\os.py", line 157, in makedirs”,  
" mkdir(name, mode)",  
“WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: ‘\\\\’”

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 8, 2020, 10:14am UTC](https://forum.ansible.com/t/how-to-run-the-python-script-from-ansible-to-windows-2019/32884/2 "2020-05-08T10:14:36Z")

</div>

To answer your question more information is needed. Could you please  
describe clearly all of the below:

- What goal you are trying to achieve.  
- How you are doing this.  
- What problems you encounter.  
- Which commands did you run, and what actual output did you get  
(copied as plain text - not as screenshots, images, or other binary  
attachments).  
- What do the relevant inventory/tasks/playbooks/code/variables look like.  
- The output of ‘ansible --version’

---

<div class="post-metadata">

**Author:** ![Dhilipsingh\_G](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@Dhilipsingh\_G](https://forum.ansible.com/u/Dhilipsingh_G)\
**Post date:** [May 8, 2020, 11:39am UTC](https://forum.ansible.com/t/how-to-run-the-python-script-from-ansible-to-windows-2019/32884/3 "2020-05-08T11:39:46Z")

</div>

hi

- What goal you are trying to achieve  
I need to run the python script on windows machine by ansible
- How you are doing this.  
i have python script on windows machine then i write the bat file for run the python script , python installed on "F:\Python27\ArcGISx6410.7\python.exe .  
my bat file is cd “F:\scc\_install\_dir\EGDMSDatabaseDeploy”  
“F:\Python27\ArcGISx6410.7\python.exe” “EGDMSDatabaseDeploy.py”  
exit  
EGDMSDatabaseDeploy.py is the python script name

Cmd and error

fatal: [10.105.83.32]: FAILED! =\> {  
“changed”: true,  
“cmd”: “db.bat”,  
“delta”: “0:00:13.881565”,  
“end”: “2020-05-08 11:32:14.295884”,  
“msg”: “non-zero return code”,  
“rc”: 1,  
“start”: “2020-05-08 11:32:00.414319”,  
“stderr”: “The filename, directory name, or volume label syntax is incorrect .\r\nTraceback (most recent call last):\r\n File "F:\FileShare\FTPRoot\Chid ambaram\_Files\DBDeploy\EGDMSDatabaseDeploy\_v3\_4\_14.py", line 874, in \r\n DatabaseCreator().main()\r\n File "F:\FileShare\FTPRoot\Chidambaram \_Files\DBDeploy\EGDMSDatabaseDeploy\_v3\_4\_14.py", line 788, in main\r\n os. makedirs(self.ECRF\_FGDB\_PATH)\r\n File "F:\Python27\ArcGISx6410.7\lib\os.p y", line 150, in makedirs\r\n makedirs(head, mode)\r\n File "F:\Python27\ \ArcGISx6410.7\lib\os.py", line 150, in makedirs\r\n makedirs(head, mode)\ r\n File "F:\Python27\ArcGISx6410.7\lib\os.py", line 150, in makedirs\r\n makedirs(head, mode)\r\n File "F:\Python27\ArcGISx6410.7\lib\os.py", line 157, in makedirs\r\n mkdir(name, mode)\r\nWindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: ‘\\\\’\r\n”,  
“stderr\_lines”: [  
“The filename, directory name, or volume label syntax is incorrect.”,  
“Traceback (most recent call last):”,  
" File "F:\FileShare\FTPRoot\Chidambaram\_Files\DBDeploy\EGDMSData baseDeploy\_v3\_4\_14.py", line 874, in “,  
" DatabaseCreator().main()”,  
" File "F:\FileShare\FTPRoot\Chidambaram\_Files\DBDeploy\EGDMSData baseDeploy\_v3\_4\_14.py", line 788, in main",  
" os.makedirs(self.ECRF\_FGDB\_PATH)“,  
" File "F:\Python27\ArcGISx6410.7\lib\os.py", line 150, in makedi rs”,  
" makedirs(head, mode)“,  
" File "F:\Python27\ArcGISx6410.7\lib\os.py", line 150, in makedi rs”,  
" makedirs(head, mode)“,  
" File "F:\Python27\ArcGISx6410.7\lib\os.py", line 150, in makedi rs”,  
" makedirs(head, mode)“,  
" File "F:\Python27\ArcGISx6410.7\lib\os.py", line 157, in makedi rs”,  
" mkdir(name, mode)",  
“WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: ‘\\\\’”  
],  
“stdout”: “\r\nF:\FileShare\FTPRoot\Chidambaram\_Files\DBDeploy\>##"F:\F ileShare\FTPRoot\Chidambaram\_Files\DBDeploy"\r\n\r\nF:\FileShare\FTPRoot\ Chidambaram\_Files\DBDeploy\>"F:\Python27\ArcGISx6410.7\python.exe" "F:\Fi leShare\FTPRoot\Chidambaram\_Files\DBDeploy\EGDMSDatabaseDeploy\_v3\_4\_14.py" \r\n\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\r\n\*\*\* EGDMS v2.0 DATAB ASE DEPLOYMENT PROCESS _ **\r\n** _\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* \*\*\*\*\*\*\*\*\r\n\r\nReading configuration settings…\r\n\r\nF:\FileShare\FTPRoot\ \Chidambaram\_Files\DBDeploy\>exit\r\n”,  
“stdout\_lines”: [  
“”,  
“F:\FileShare\FTPRoot\Chidambaram\_Files\DBDeploy\>##"F:\FileShare\ FTPRoot\Chidambaram\_Files\DBDeploy"”,  
“”,  
"F:\FileShare\FTPRoot\Chidambaram\_Files\DBDeploy\>"F:\Python27\Arc GISx6410.7\python.exe" "F:\FileShare\FTPRoot\Chidambaram\_Files\DBDeploy\ EGDMSDatabaseDeploy\_v3\_4\_14.py" ",  
“_**",  
" EGDMS v2.0 DATABASE DEPLOYMENT PROCESS ",  
"**_”,  
“”,  
“Reading configuration settings…”,  
“”,  
“F:\FileShare\FTPRoot\Chidambaram\_Files\DBDeploy\>exit”  
]  
}

-Ansible version

ansible 2.9.6  
config file = /etc/ansible/ansible.cfg  
configured module search path = [u’/home/dgunasin/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]  
ansible python module location = /usr/lib/python2.7/site-packages/ansible  
executable location = /usr/local/bin/ansible  
python version = 2.7.5 (default, Jun 11 2019, 14:33:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

---

<div class="post-metadata">

**Author:** ![Dhilipsingh\_G](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@Dhilipsingh\_G](https://forum.ansible.com/u/Dhilipsingh_G)\
**Post date:** [May 8, 2020, 11:50am UTC](https://forum.ansible.com/t/how-to-run-the-python-script-from-ansible-to-windows-2019/32884/4 "2020-05-08T11:50:52Z")

</div>

i am getting result when i run the bat file manually on windows machine ,

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [May 8, 2020, 12:24pm UTC](https://forum.ansible.com/t/how-to-run-the-python-script-from-ansible-to-windows-2019/32884/5 "2020-05-08T12:24:45Z")

</div>

You forgot the most important information ^^^

---

<div class="post-metadata">

**Author:** ![Dhilipsingh\_G](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@Dhilipsingh\_G](https://forum.ansible.com/u/Dhilipsingh_G)\
**Post date:** [May 8, 2020, 12:38pm UTC](https://forum.ansible.com/t/how-to-run-the-python-script-from-ansible-to-windows-2019/32884/6 "2020-05-08T12:38:16Z")

</div>



---

<div class="post-metadata">

**Author:** ![Dhilipsingh\_G](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@Dhilipsingh\_G](https://forum.ansible.com/u/Dhilipsingh_G)\
**Post date:** [May 10, 2020, 3:16pm UTC](https://forum.ansible.com/t/how-to-run-the-python-script-from-ansible-to-windows-2019/32884/7 "2020-05-10T15:16:04Z")

</div>

hi ,anyone have idea ?

---

<div class="post-metadata">

**Author:** ![Dhilipsingh\_G](https://avatars.discourse-cdn.com/v4/letter/d/df788c/32.png) [@Dhilipsingh\_G](https://forum.ansible.com/u/Dhilipsingh_G)\
**Post date:** [May 11, 2020, 10:42am UTC](https://forum.ansible.com/t/how-to-run-the-python-script-from-ansible-to-windows-2019/32884/8 "2020-05-11T10:42:20Z")

</div>

Hi any suggestions plz

hi ,anyone have idea ?
