Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'disciplines': 0.07; 'received:edu.au': 0.07; 'stuff,': 0.07; 'subject:while': 0.07; 'tab': 0.07; 'subject:Problem': 0.09; 'subject:file': 0.13; 'cc:addr:python-list': 0.15; '"cat': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'mode;': 0.16; 'pty': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'wrote:': 0.16; 'linux': 0.17; '>>>': 0.18; 'expansion': 0.18; 'rewrite': 0.18; 'jan': 0.19; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'changed': 0.23; 'obviously': 0.23; 'expanded': 0.23; 'cc:2**0': 0.25; 'mode': 0.25; 'expect': 0.26; 'fix': 0.27; 'print': 0.29; 'cc:addr:python.org': 0.29; "ain't": 0.30; 'invoke': 0.30; 'certainly': 0.32; 'actually': 0.32; 'does': 0.32; 'that,': 0.32; "can't": 0.32; 'header:User-Agent:1': 0.33; 'instead': 0.33; 'solaris': 0.34; 'something': 0.35; 'expanding': 0.35; 'file': 0.35; 'received:au': 0.36; 'charset:us-ascii': 0.36; 'run': 0.37; 'but': 0.37; 'using': 0.37; 'created': 0.38; 'subject:with': 0.38; 'think': 0.38; 'should': 0.38; 'ok,': 0.39; 'subject:: ': 0.39; 'most': 0.60; 'quick': 0.60; 'your': 0.61; 'received:202': 0.65; 'show': 0.67; 'ali': 0.67; 'discipline': 0.67; 'present.': 0.67; 'spaces': 0.73; 'cameron': 0.77; '12:42': 0.84; 'saqib': 0.84; 'so:': 0.84; 'spaces.': 0.84; 'glance': 0.91 Date: Mon, 16 Jan 2012 12:45:35 +1100 From: Cameron Simpson To: Saqib Ali Subject: Re: Problem while doing a cat on a tabbed file with pexpect MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) References: Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326678340 news.xs4all.nl 6874 [2001:888:2000:d::a6]:52285 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:19024 On 15Jan2012 16:14, Saqib Ali 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 DoD#743 http://www.cskk.ezoshosting.com/cs/ Maintainer's Motto: If we can't fix it, it ain't broke.