🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #8548

Re: Programacion Script

#8548
From: zd
Date: Wed, 30 Oct 2002 22:39
73 lines
2887 bytes
Sand Man <sand_man@terra.es> escribi�:

> Hola,
> 
> Alguien me podria decir como pudeo programar un scrip que:
> 
> 1� Identifique el PID de  un proceso del cual se conoce el nombre.
> 2� Matar ese proceso por su numero de PID.

Aunque me parece extra�a esa petici�n, aqu� va eso:

---- C�DIGO ----

#!/bin/bash

MAL_ARG=65
MAL_SEL=66
NO_PERM=67

if [ "${1}" = "" ]; then
    echo
    echo "Tienes que especificar un proceso."
    exit $MAL_ARG
else
    CORRE="$(echo $(ps -Ao comm | grep ${1}))"
    if [  "$CORRE" = "" ]; then
        echo
        echo "El proceso no est� ejecut�ndose. Saliendo..."
        exit 0
    else
        echo
        PROCESO="$(ps -Ao comm | grep "${1}")"
        PID=($(ps -Ao pid,comm | grep "${1}"))
        echo -n "�Desea matar el proceso \""$PROCESO"\" cuyo identificador \
es, \""${PID[0]}"\"?; [S/N]: "
        read SEL
        case "$SEL" in
            [s,S])
                if kill -9 "$PID" &>/dev/null ; then
                    echo
                    echo "Hecho. Saliendo..."
                    exit 0
                else
                    echo
                    echo "Operaci�n no permitida. Saliendo..."
                    exit $NO_PERM
                fi
                ;;
            [n,N])
                echo
                echo "Saliendo..."
                exit 0
                ;;
            *)
                echo
                echo "Opci�n incorrecta. Saliendo..."
                exit $MAL_SEL 
                ;;
        esac
    fi
fi

exit 0

---- C�DIGO ----

Un saludo.


-- 
Zeles Deree (zeldere)   .zd
 * Correo: zeldere@yahoo.es
 * GNU/Linux - LFS 3.1
Technical Details
Message-ID: <appn2j$bh9$1@titan.bt.es>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!kibo.news.demon.net!demon!btnet-peer0!btnet-peer!btnet!newsfeed.bt.es!news.bt.es!not-for-mail
References: <appg5h$ch5$1@nsnmrro2-gest.nuria.telefonica-data.net>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,28cffd7948076415
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-10-30 14:57:45 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!kibo.news.demon.net!demon!btnet-peer0!btnet-peer!btnet!newsfeed.bt.es!news.bt.es!not-for-mail
From: zd <zeldere|_nospam|@yahoo.es>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Programacion Script
Supersedes: <appmes$bdl$1@titan.bt.es>
Date: 30 Oct 2002 22:39:15 GMT
Organization: BT Tel. Netnews service (readers)
Lines: 73
Message-ID: <appn2j$bh9$1@titan.bt.es>
References: <appg5h$ch5$1@nsnmrro2-gest.nuria.telefonica-data.net>
NNTP-Posting-Host: cable223a208.usuarios.retecal.es
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-15
Content-Transfer-Encoding: 8bit
X-Trace: titan.bt.es 1036017555 11817 212.183.223.208 (30 Oct 2002 22:39:15 GMT)
X-Complaints-To: abuse@bt.es
NNTP-Posting-Date: 30 Oct 2002 22:39:15 GMT
User-Agent: slrn/0.9.7.3 (Linux)