Thread: Getting Console / Terminal Text With PID

  1. #1
    Registered User
    Join Date
    Jan 2014
    Posts
    139

    Getting Console / Terminal Text With PID

    Hello,

    I have a linux pc that will run a console terminal (3rd party app) that I want to monitor the output of and alert me of certain conditions.

    Is there a way to get the output of the console/terminal with just the pid id? I read about stdout but that requires you to start the process which I cannot always do. How can I get the output of the window when all I have is the PID?

    Thanks in advance.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    Do you have root privilege on the machine in question?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jan 2014
    Posts
    139
    thanks for the reply, yes i do have root

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,656
    sudo strace -p12345 -e write
    For a process PID=12345

    strace(1): trace system calls/signals - Linux man page
    The -e option has many ways to control the verbosity of output.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    It's somewhat of a hack, but you can. You need to be root and know the PID of the process. This link explains it:
    https://etbe.coker.com.au/2008/02/27...nning-process/
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Flashing Text in Linux Terminal
    By gemera in forum Linux Programming
    Replies: 8
    Last Post: 01-17-2013, 02:51 PM
  2. How do I use a text terminal as a bitmap?
    By PedroTuga in forum C Programming
    Replies: 5
    Last Post: 12-08-2012, 06:05 PM
  3. Replies: 7
    Last Post: 08-28-2011, 09:01 PM
  4. Replies: 2
    Last Post: 02-11-2011, 04:45 AM
  5. Console, Terminal and Terminal Emulator
    By lehe in forum C Programming
    Replies: 4
    Last Post: 02-15-2009, 09:59 PM

Tags for this Thread