Hi Guys,

I'm new to python - how to execute dos2unix from python - subprocess.popen with shell = False ?

>>> cmd = subprocess.Popen(["dos2unix","./FEED1/bin/*"], stdout=subprocess.PIPE)
dos2unix: converting file ./FEED1/bin/* to UNIX format ...
>>> dos2unix: problems converting file ./FEED1/bin/*

All help appreciated.

Probably with glob.glob

import glob
import subprocess
filelist = glob.glob("./FEED1/bin/*")
if filelist:
    cmd = subprocess.Popen(["dos2unix"] + filelist, stdout=subprocess.PIPE)

see also this snippet http://www.daniweb.com/software-development/python/code/257449

Sorry tht does not work for me

>>> cmd = subprocess.Popen(["dos2unix"]+filelist, stdout=subprocess.PIPE) dos2unix: converting file ./FEED1/bin/File1.pl to UNIX format ...
>>> dos2unix: problems converting file ./FEED1/bin/File1.pl

And the same command from xterm in the script directory works?

Edited 4 Years Ago by pyTony: n/a

This article has been dead for over six months. Start a new discussion instead.