Displaying output in new terminal window

This is a discussion on Displaying output in new terminal window within the C Programming forums, part of the General Programming Boards category; Hello, I'm currently doing noob level UNIX C programming, and I am trying to display output in a new terminal ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    8

    Displaying output in new terminal window

    Hello, I'm currently doing noob level UNIX C programming, and I am trying to display output in a new terminal window, and I don't know how to do that. Could any of you gents point me in the right direction please?

    Thanks in advance.

  2. #2
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    Do you mean create a new terminal window, or display output?
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  3. #3
    Registered User
    Join Date
    Dec 2006
    Posts
    8
    I'm sorry, I mean running a pager program like less in a new window to display the output.

  4. #4
    MFC killed my cat! manutd's Avatar
    Join Date
    Sep 2006
    Location
    Boston, Massachusetts
    Posts
    870
    I'm not following what you want. Try to explain in more than one sentence
    Silence is better than unmeaning words.
    - Pythagoras
    My blog

  5. #5
    Registered User
    Join Date
    Nov 2006
    Posts
    176
    you'll have to use execl or similar to execute the command to open a new window (xterm or whatever you use). You'll also have to supply xterm with the correct commandline to execute whatever program (less I think you said) it is supposed to run when it opens.

  6. #6
    Registered User
    Join Date
    Dec 2006
    Posts
    8
    It is a very stupid request, but I'm working on a class project.

    Basically, I am collecting output of a program with a pipe, and trying to display it in a new terminal window by having that new window execute less/more/whatever paging utility the user specifies.

  7. #7
    Registered User
    Join Date
    Dec 2006
    Posts
    8
    Quote Originally Posted by sl4nted
    you'll have to use execl or similar to execute the command to open a new window (xterm or whatever you use). You'll also have to supply xterm with the correct commandline to execute whatever program (less I think you said) it is supposed to run when it opens.
    Thank you very much. I never thought to suspect xterm had a command line operator that would take a program I wanted it to run.

  8. #8
    Registered User
    Join Date
    Nov 2006
    Posts
    176
    I donno if it does, that was an example....Eterm does I'm pretty positive I've done it with that before. xterm may, but don't get your hopes up

    edit::
    man xterm
    I guess it does
    -e
    same as eterm if I remember right
    Last edited by sl4nted; 12-07-2006 at 05:02 PM.

  9. #9
    Registered User
    Join Date
    Dec 2006
    Posts
    8
    Okay, I got another problem. The information I have is in a pipe. If I write something like execl("/.../xterm", "-e", "less...) ... how can I pass that pipe to forked/execled xtermed less?

  10. #10
    Registered User
    Join Date
    Nov 2006
    Posts
    176
    by pipe I assume its just a buffer in your program? not the IPC object

    :: you could just write it to a file and run less or whatever command on that file
    Last edited by sl4nted; 12-07-2006 at 07:01 PM.

  11. #11
    Registered User
    Join Date
    Dec 2006
    Posts
    8
    It is an IPC object. My program uses it to collect the output of one fork/execl combo and then needs to feed it into another.

    Writing it to a file and running less on that file would be the sane way to do it, but this is a school project, so I am required to do everything the non-intuitive way, score a ten semicolon hit combo, and invent the improbability drive without touching the ground.

    I take it from your tone that this is a ridiculous question, and it probably is. I know less can read pipes, but I don't know how to give the read pointer of the pipe to the less I'm execling.

  12. #12
    Registered User
    Join Date
    Nov 2006
    Posts
    176
    I take it from your tone that this is a ridiculous question, and it probably is

    -- not at all

    I had to do somthing basically like this for university awhile ago (3-4 years), we created a shell, and it piped data between basically any 2 processes. I'm thinking it has to do with using stdin/stdout. But am not positive just yet (but I almost am)....lemme see if I can dig up my old shell program, it should be archive on here somwhere

    sry, not seeing it anywhere

    I did think maybe you should use popen, but thats not gonna help I don't think since it has to be opened in a seperate xterm
    Last edited by sl4nted; 12-07-2006 at 08:08 PM.

  13. #13
    Registered User
    Join Date
    Dec 2006
    Posts
    8
    Well, I know the only reliable way I have at this point of getting a pipe to be readable to a child process after an exec is by fixing the pipe to stdin/out, but I just need to get less to read out of it.

    popen really won't work. But if I have the pipe in stdin/stdout's file descriptor spots before I execl the xterm window, then the pipe will be ACCESSIBLE, but I just need to know how to get less to access it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Displaying my glut output in my own class window.
    By Queatrix in forum Windows Programming
    Replies: 0
    Last Post: 10-19-2005, 10:09 AM
  2. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  3. my wndProc is out of scope
    By Raison in forum Windows Programming
    Replies: 35
    Last Post: 06-25-2004, 07:23 AM
  4. Displaying data in a new window
    By mrprogrammer in forum Windows Programming
    Replies: 1
    Last Post: 04-21-2004, 10:11 AM
  5. OpenGL and Windows
    By sean345 in forum Game Programming
    Replies: 5
    Last Post: 06-24-2002, 10:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21