How to get columns TIME and TTY of commands ps -A?


 
Thread Tools Search this Thread
Operating Systems Linux Ubuntu How to get columns TIME and TTY of commands ps -A?
# 1  
Old 07-16-2012
How to get columns TIME and TTY of commands ps -A?

Hi,
Commands ps -A include four parameters are PID, TTY, TIME and CMD. I can not found pathnames of TTY and TIME which I can read from file in C language to get information display on screen. Thank you!

Ex:
PID TTY TIME CMD
1 ? 00:00:01 init
# 2  
Old 07-16-2012
Do you mean the /proc directories? /proc/pid, from your example /proc/1
is the path.

However TIME comes from /var/adm/utmpx - you will have to use a structure defined in utmpx.h to read the file.

example code here:
loginacct/utmpx_login.c (from "The Linux Programming Interface")

As to the TTY, what are you trying to do?

/proc/pid/fd/0 is the tty for the process, if one exists. A ? in ps -A output means the process does not have a controlling terminal.
# 3  
Old 07-18-2012
Thank you, but I see /proc/pid/fd/0 a socket, I cannot read it by C language cause I need read "TTY" to display the screen.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Python: Redirecting to tty and reading from tty

In bash, you can do something like this: #!/bin/bash echo -n "What is your name? " > /dev/tty read thename < /dev/tty How can I do the same in python? I have a python script that has the following content: #!/usr/bin/python2.7 import getpass import sys import telnetlib import... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

How to time stamp executed commands?

Hi guys, I am executing a pretty long ksh script and need to time stamp every command which runs inside. Unfortunatly 'echo date' is not the option here. May be someone knows another way or utility which can be used to log executed command and timestamp next to it. Thanks PS I work in ksh88 (4 Replies)
Discussion started by: aoussenko
4 Replies

3. Shell Programming and Scripting

Using array commands in 2 files in the same time

Hi bodies. You think is it possible to make arrays from 2 different files in a same time and then for example compare the values in these 2 arrays or any other instruction for example, I have: 38558 29 31 38557 28 31 38556 23 31 38555 08 31 38554 08 28 38553 21... (8 Replies)
Discussion started by: Behrouzx77
8 Replies

4. Shell Programming and Scripting

command to remove multiple commands in particular columns

Hi Experts, I actually need to remove multiple commas within the column not the entire row. Its comma delimited file Actually the value seems to look like 1,006,000, when we open this in notepad or word pad the value look s like “1,006,000” Actually our Sed command removes single comma and... (7 Replies)
Discussion started by: bshivali
7 Replies

5. UNIX for Dummies Questions & Answers

/dev/tty find last modified time

what can I use to find the last modified time of a /dev/tty ? (4 Replies)
Discussion started by: l flipboi l
4 Replies

6. Shell Programming and Scripting

Execute 2 Commands at the same time

Hi @all I have got the following problem: I want my Master-Script to execute 2 Sub-scripts at the same time. How can i realize that? Thx for your help Greez Roger (2 Replies)
Discussion started by: DarkSwiss
2 Replies

7. UNIX for Dummies Questions & Answers

multiple commands to be executed at the same time

how to execute more than one command at the same time in unix .. (4 Replies)
Discussion started by: hemaa
4 Replies

8. Shell Programming and Scripting

POSIX way of getting columns in tty?

Is there a POSIX compatible way of getting the number of columns in a tty? On Linux, I can do something like: stty -a | awk -F'' '/columns/ { print $9 }' But will that work on AIX, Solaris, etc? (13 Replies)
Discussion started by: otheus
13 Replies

9. Shell Programming and Scripting

Run several commands at a time

Hello guys, I am new at shell scripting and I want to create a script that runs several commands at a time, ie: uptime, w, df -h and so on and send the output of this commands to a text file so it can be send via email at a certain time using crontab. Any help will be much appreciated! (4 Replies)
Discussion started by: agasamapetilon
4 Replies

10. UNIX for Dummies Questions & Answers

To club to commands with columns

Hi, I've a requirement to display all the attributes of the directory which may contain directory also along with the files and additionally i need to display the versions of the files present in the directory along with the column of "ls -ltr" which will be in next column(Version) Plz give... (2 Replies)
Discussion started by: darshang
2 Replies
Login or Register to Ask a Question