CRLF when doing os.system("ls -l") while using curses !!!

L

lkennedy5

Here is the code and as you can see for yourself, the output is not
coming out on the screen with CRLF like it should. How do I fix this?



import curses, os
screen = curses.initscr()
os.system("ls -l")
curses.endwin()
 
E

Emile van Sebille

On 5/29/2009 1:34 PM (e-mail address removed) said...
Here is the code and as you can see for yourself, the output is not
coming out on the screen with CRLF like it should.

Mine did:

[root@falcon]# python2
Python 2.3.3 (#1, May 11 2004, 14:44:08)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-85)] on linux2
Type "help", "copyright", "credits" or "license" for more information.total 8
drwxr-xr-x 4 root root 4096 Apr 28 14:42 fal
drwxr-xr-x 4 root root 4096 Apr 28 14:43 home

How do I fix this?

Provide details on your environment so others can duplicate the error.

Emile
 
P

Piet van Oostrum

l> Here is the code and as you can see for yourself, the output is not
l> coming out on the screen with CRLF like it should. How do I fix this?

Don't use curses.

Curses puts the terminal in raw mode (more or less) which doesn't
translate the newline character into CRLF. If you use curses you are
supposed to do all output through curses. But the os.system goes
directly to the screen, outside of curses (because it is another
process).
You could catch the output of ls -l with a PIPE and then write the
output to the curses screen with addstr. But a curses screen has a
limited length, whereas your ls -l output may be larger so then you must
implement some form of scrolling.
 
L

lsk040365

Don't use curses.

Curses puts the terminal in raw mode (more or less) which doesn't
translate the newline character into CRLF. If you use curses you are
supposed to do all output through curses. But the os.system goes
directly to the screen, outside of curses (because it is another
process).
You could catch the output of ls -l with a PIPE and then write the
output to the curses screen with addstr. But a curses screen has a
limited length, whereas your ls -l output may be larger so then you must
implement some form of scrolling.

Can you provide me with some sort of example possibly--I have been
fighting this for a while and I wouldn't be using curses but I have
designed the program with the extended ascii characters thereby making
a nice UI...?

Thanks in advance,
Lee
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,266
Latest member
DavidaAlla

Latest Threads

Top