0

I have written a small python script but bash won't execute it:

#!/usr/bin/python

'''
Created on Dec 19, 2014


'''
import subprocess


if __name__ == '__main__':
    p = subprocess.Popen('df -h', stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
    out,err = p.communicate()
    for o in out.splitlines():
        if('rootfs' in o):
            print o.split()[3]

When I run ./te.py, bash gives me an error:

-bash: ./te.py: /usr/bin/python^M: bad interpreter: No such file or directory

What's the problem?

matsjoyce
  • 5,744
  • 6
  • 31
  • 38
abbas-h
  • 392
  • 1
  • 4
  • 18

1 Answers1

0

try this one:

#!/usr/bin/env python
Hackaholic
  • 19,069
  • 5
  • 54
  • 72
  • 4
    This doesn't solve the problem of the line endings. If the OP had line ending issues before, chances are they'll have line ending issues with this version. – Ffisegydd Dec 19 '14 at 13:23