error when running python script to call lammps

Dear Lammps users,

I’ve wrote a python script (attached) to call Lammps and do some analysis. However, I found the script runs fine if I directly use:
python script.py

but will generate the following error if I use:
python script.py>script.output

Error message:

File “regional_diffusion_lammps_Pyversion.py”, line 55, in
extract_y(12, 40.129, 64.129, 92.258, 2)
File “regional_diffusion_lammps_Pyversion.py”, line 21, in extract_y
y=L.atoms[i].position[1]
File “/share/apps/lammps-11Aug17/python/lammps.py”, line 643, in atoms
return AtomList(self)
File “/share/apps/lammps-11Aug17/python/lammps.py”, line 465, in init
self.natoms = self.lmp.system.natoms
File “/share/apps/lammps-11Aug17/python/lammps.py”, line 648, in system
d = self._parse_info_system(output)
File “/share/apps/lammps-11Aug17/python/lammps.py”, line 699, in _parse_info_system
lines = output[6:-2]
TypeError: ‘NoneType’ object has no attribute ‘getitem

Could you please help with this problem? Thank you!

regional_diffusion_lammps_Pyversion.py (1.81 KB)

I have no idea why piping the output to script.output would

fail with that kind of error. Maybe Richard (CCd) has an idea.

Steve