0

I'm trying to display the "Phrack" text files. The problem is that the screen doesn't clear before displaying the text file. And overwrites whatever is on the screen at the time. I've tried printf() declarations, like printf("^[[2J") and printf("^[[22;1H") and so forth. And various ncurses "clear screen" commands. None of which worked. Here's the line:

system("/usr/bin/stty -raw") | system("/usr/bin/cat /home/imp/phrack/1/P01-01") | system("/usr/bin/stty -cooked");

Thanks.

LPs
  • 16,045
  • 8
  • 30
  • 61
user2411434
  • 109
  • 1
  • 4
  • amongst other things, no where in that line is the screen cleared and no where in that line is the cursor moved to the upper left corner of the screen. – user3629249 Oct 25 '16 at 08:05
  • what is the contents of the `phrack` file? is it text or is it the output from some wordprocessor? Why do you want to change to 'raw' mode to write the contents of the file? – user3629249 Oct 25 '16 at 08:07
  • Note: when the terminal is in 'raw' mode, the program has to supply all the cursor movement actions Other wise the text will be displayed on the screen as a long string of bytes, with no line formatting, etc. This means the control characters withing the file, like linefeed and tab and newline will just be displayed as (in general) unprintable characters – user3629249 Oct 25 '16 at 08:10
  • The `phrack` file is a plain text file. The reason for the `stty -raw` command, is that without it, it doesn't display the text (`phrack`) file correctly.. – user2411434 Oct 25 '16 at 21:29

1 Answers1

1

The line

printf("^[[2J")

and the tag c indicate that OP wants to write a program in C to clear the screen. The problem with that line is that there's no escape character. This would work:

printf("\033[H\033[2J"); fflush(stdout);

because it uses the escape character. I added the fflush to make it happen "now" rather than sometime later.

There are no uses of ncurses in the question.

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • Yes. It does display the escape character. The `^[` in `^[[2J` is an "escape character". As far as `ncurses`, I meant that I tried using the `clear` command, and compiled the program with `-lncurses'. No luck. – user2411434 Oct 25 '16 at 21:32
  • I'm not sure if i'm allowed to do this, but here is the source for the full program. `http://www.catch22bbs.com/phrack.c` – user2411434 Oct 25 '16 at 22:01