What process is listening on a certain port on Solaris?

后端 未结 11 1204
情话喂你
情话喂你 2020-12-13 02:24

So I log into a Solaris box, try to start Apache, and find that there is already a process listening on port 80, and it\'s not Apache. Our boxes don\'t have lsof installed,

11条回答
  •  一向
    一向 (楼主)
    2020-12-13 02:55

    I think the first answer is the best I wrote my own shell script developing this idea :

    #!/bin/sh
    if [ $# -ne 1 ]
    then
        echo "Sintaxis:\n\t"
        echo " $0 {port to search in process }"
        exit
    else
        MYPORT=$1
        for i in `ls /proc`
        do
    
           pfiles $i | grep port | grep "port: $MYPORT" > /dev/null
           if [ $? -eq 0 ]
             then
               echo " Port $MYPORT founded in $i proccess !!!\n\n"
               echo "Details\n\t"
               pfiles $i | grep port | grep "port: $MYPORT"
               echo "\n\t"
               echo "Process detail: \n\t"
               ps -ef | grep $i  | grep -v grep
           fi
        done
    fi
    

提交回复
热议问题