Sponsored Content
Top Forums Shell Programming and Scripting Need generic command to get complete running process details Post 302995288 by drysdalk on Tuesday 4th of April 2017 08:43:39 AM
Old 04-04-2017
Hi,

The basic idea is to step through every PID on the system, run pfiles against it, and if any of the output lines contain AF_INET then those are the sockets that PID has open.

Here's a quick example script I've written. Caveats: this was tested on Tribblix, an illumos distribution, rather than "proper" Solaris, so to speak (since that's what I'm running on my current workstation). But it worked for me, and should work on Solaris 10 as well.

Code:
#!/bin/bash
for pid in `/usr/bin/ps -aef -o pid`
do
        if /usr/bin/pfiles $pid 2>/dev/null | /usr/bin/grep AF_INET 2>/dev/null
        then
                echo Above sockets belong to PID $pid
                echo -----
        fi
done

Run this and you'll get the idea. Hope this helps.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to find the details of the previously running process with PID

OS: Unix or Linux I (only) know the pid of the process which was running earlier (say 5 hrs back) but it is not running now. Is there a way I could find the details of that process? (atleast the name of the process). Please let me know. (2 Replies)
Discussion started by: vijay.d
2 Replies

2. UNIX for Dummies Questions & Answers

Command to check if a particular process is running

Hi What is the best command to check if a particular process is running in a linux server or not To check any java process, I use the below command. ps -ef |grep jvm When I execute the above command, it lists me all the processess . The above command should ideally return only the... (6 Replies)
Discussion started by: vr3w3c9
6 Replies

3. Shell Programming and Scripting

Running a command in a new process?

Hello I'm using GNU screen for an application that I'm making. I will try to explain: This application opens 2 screen session, A and B. Screen session A has a script running in teh first window. I want to be able to switch from screen session A to screen session B, from the script running in... (1 Reply)
Discussion started by: jondecker76
1 Replies

4. Shell Programming and Scripting

command to see process running at background

Hi , I want to see all the background process that are running in unix box machine...please guide me is there any specific command for that..since I am executing some scripts at background..!!:confused: (1 Reply)
Discussion started by: nks342
1 Replies

5. Solaris

Process holding /tmp space, need to know the process details

Hi , In a server /tmp has almost reached 75% and i can see the File system utilization is 48Mb only , so i believe some process is using the /tmp space. I would like to know which process is using /tmp space. # df -h /tmp Filesystem size used avail capacity Mounted on swap ... (9 Replies)
Discussion started by: chidori
9 Replies

6. Shell Programming and Scripting

Show running process command > 60 chars

Hi. I use this command to get list of running process: ps -ef|grep ICP|grep -v grep But how do I set the terminal to show full command? It seems that it always truncated to 60 chars no matter what options I put. e.g output oracle9 25011 24998 0 03:00:05 ? 0:00 /usr/bin/sh... (14 Replies)
Discussion started by: aimy
14 Replies

7. Shell Programming and Scripting

Command to know all the Current running process and how to kill

All, 1.What is the unix comand used for all current running process (Including All current running processes Parent ->child->subchild process) 2.If child and subchild processes are running then what is the unix command to kill parent and its all child subchild processes in UNIX. Kindly... (7 Replies)
Discussion started by: skp
7 Replies

8. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies

9. Shell Programming and Scripting

Check if process is running if not then use command

Hello, Could someone do the following bash ubuntu script for me? I have 5 screen processes of bot: SCREEN -dmS Xbot_instance_1 php core.php -i 1 SCREEN -dmS Xbot_instance_2 php core.php -i 2 SCREEN -dmS Xbot_instance_3 php core.php -i 3 SCREEN -dmS Xbot_instance_4 php core.php -i 4 ... (2 Replies)
Discussion started by: kotch
2 Replies

10. UNIX for Beginners Questions & Answers

Generic script to load file details(ls -ltr) in to a database.

All, I am trying to create a report on the duration of an ETL load from the file arrival to the final dump in to a database for SLA's. Does anyone have any guidance or ideas on how metadata can be extracted; information of a file: like file name, created timestamp, count of records and load... (1 Reply)
Discussion started by: pradeepp
1 Replies
getusershell(3C)					   Standard C Library Functions 					  getusershell(3C)

NAME
getusershell, setusershell, endusershell - get legal user shells SYNOPSIS
#include <unistd.h> char *getusershell(void); void setusershell(void); void endusershell(void); DESCRIPTION
The getusershell() function returns a pointer to a legal user shell as defined by the system manager in the file /etc/shells. If /etc/shells does not exist, the following locations of the standard system shells are used in its place: /bin/bash /bin/csh /bin/jsh /bin/ksh /bin/pfcsh /bin/pfksh /bin/pfsh /bin/sh /bin/tcsh /bin/zsh /sbin/jsh /sbin/pfsh /sbin/sh /usr/bin/bash /usr/bin/csh /usr/bin/jsh /usr/bin/ksh /usr/bin/pfcsh /usr/bin/pfksh /usr/bin/pfsh /usr/bin/sh /usr/bin/tcsh /usr/bin/zsh /usr/xpg4/bin/sh The getusershell() function opens the file /etc/shells, if it exists, and returns the next entry in the list of shells. The setusershell() function rewinds the file or the list. The endusershell() function closes the file, frees any memory used by getusershell() and setusershell(), and rewinds the file /etc/shells. RETURN VALUES
The getusershell() function returns a null pointer on EOF. BUGS
All information is contained in memory that may be freed with a call to endusershell(), so it must be copied if it is to be saved. SunOS 5.10 30 Aug 2004 getusershell(3C)
All times are GMT -4. The time now is 05:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy