Hi

I am working on Linux with Python 3.4.

I want to do a bash diff on two text files and show just the first 20 lines of 
diff's output.  So I tried:

>>> cmd = 'head -20 <(diff ' + file1 + ' ' + file2 + ')'
>>> subprocess.check_call(cmd, shell=True)

The command contained in cmd works ok from the bash prompt but not from Python 
code.  In Python I get:

/bin/sh: -c: line 0: syntax error near unexpected token `('

I think the problem is that check_call is not using the bash shell.  So I also 
tried:

>>> subprocess.check_call("bash", "-O", "extglob", "-c", cmd)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/subprocess.py", line 556, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/local/lib/python3.4/subprocess.py", line 537, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/local/lib/python3.4/subprocess.py", line 767, in __init__
    raise TypeError("bufsize must be an integer")
TypeError: bufsize must be an integer

Can anyone help me with this please?

Best regards

David

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to