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.

Recommended Answers

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

Jump to Post

All 4 Replies

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

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?

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 works well. was a file permission issue..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.