On 15Jan2012 16:14, Saqib Ali <saqib.ali...@gmail.com> wrote: | The file me.txt does indeed contain tabs. I created it with vi. | | >>> text = open("me.txt", "r").read() | >>> print "\t" in text | True | | % od -c me.txt | 0000000 A \t B \t C \n | 0000006 | | % ls -al me.txt | -rw-r--r-- 1 myUser myGroup 6 Jan 15 12:42 me.txt
Ok, your file does indeed contain TABs. Therefre something is turning the TABs into spaces. Pexpect should be opening a pty and reading from that, and I do not expect that to expand TABs. So: 1: Using subprocess.Popen, invoke "cat me.txt" and check the result for TABs. 2: Using pexpect, run "cat me.txt" instead of "/bin/tcsh" (eliminates a layer of complexity; I don't actually expect changed behaviour) and check for TABs. On your Solaris system, read "man termios". Does it have an "expand TABs" mode switch? This is about the only thing I can think of that would produce your result - the pty terminal discipline is expanding TABs for your (unwanted!) - cat is writing TABs to the terminal and the terminal is passing expanded spaces to pexpect. Certainly terminal line disciplines do rewrite stuff, most obviously "\n" into "\r\n", but a quick glance through termios on a Linux box does not show a tab expansion mode; I do not have access to a Solaris box at present. Cheers, -- Cameron Simpson <c...@zip.com.au> DoD#743 http://www.cskk.ezoshosting.com/cs/ Maintainer's Motto: If we can't fix it, it ain't broke. -- http://mail.python.org/mailman/listinfo/python-list