I'm using the "sh" module in python in order to call external commands on Linux. In my particular case I would like to call the "du" command because it is more efficient than doing such calculations "by hand". Unfortunately the following line does not work:
output = sh.du('-sx', '/tmp/*')
But this does work:
output = sh.du('-sx', '/tmp/')
If I pass an asterisk I get the following error message:
'ascii' codec can't encode character u'\u2018' in position 87: ordinal not in range(128)
Does anyone know how to deal with asterisks in command line arguments?
As requested, here is the stack trace:
Traceback (most recent call last):
File "./unittest.py", line 33, in <module>
output = sh.du('-sx', '/tmp/*')
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 1021, in __call__
return RunningCommand(cmd, call_args, stdin, stdout, stderr)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 486, in __init__
self.wait()
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 500, in wait
self.handle_command_exit_code(exit_code)
File "/usr/local/lib/python2.7/dist-packages/sh.py", line 516, in handle_command_exit_code
raise exc(self.ran, self.process.stdout, self.process.stderr)
sh.ErrorReturnCode_1