Partner Sites

Netbois Consulting
facturi

Login

Statistici

Membri: 197
Stiri: 1093
Linkuri: 33
Vizitatori: 1766287

Mirror MYLRo.org

Carti Linux direct de pe mirror-ul MYLRo.org
 
Lanseaza un xterm pe un server anume E-mail
  • Currently 3.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Rating: 3.5/5 (2 votes cast)

Scris de Cypress   
Thursday, 22 November 2007
#!/bin/bash
##########################################################################
# Title      :    workon - create xterms to work on a specified host
# Author     :    Heiner Steven < Aceasta adresa e-mail este protejata impotriva spamului, JavaScript trebuie activat pentru a putea vizualiza pagina. >
# Date       :    1995-10-11
# Requires   :    isxwindows
# Category   :    Desktop
# SCCS-Id.   :    @(#) workon    1.12 06/03/03
##########################################################################
# Description
#    o    The command $XTERM needs ot understand the option "-g" and "-T",
#    e.g. "-g 80x25 -T title"
##########################################################################

PN=`basename "$0"`            # Program name
VER='1.12'                # Version number

: ${XTERM:=xterm}
: ${XTERMOPTS=}

# We need a way to ping exactly one time (Linux "ping" needs -c option)
if [ -z "$PINGONCE" ]
then
    case `uname` in
    SunOS)    PINGONCE=ping;;
    Linux)    PINGONCE="ping -c 1";;
    *)    PINGONCE="ping -c 1";;    # Default
    esac
fi

#########################################################################
# CONFIGURATION SECTION
#
#           | XOFF
#       +---|-------------------+
#       |   |-----------PX      |
# YOFF -----1111111     2222222 |
#       |   1111111     2222222 |
#       |   1111111     2222222 |
#       |   1111111     2222222 |
#       |                       |
#       +-----------------------+

# The offsets may be used to provide a fixed left or top margin for
# all windows

XOFF=153
YOFF=0

# These offsets are used for the right windows (the do not include XOFF/YOFF)

PX=503                    # Offset from the left margin
PY=514                    # Offset from the top margin

# Two window sizes

DX=80;    DY=70                # Size of wins 1 and 2

# END CONFIGURATION SECTION
#########################################################################

X=`expr ${XOFF:=0} + ${PX:=0}`
Y=`expr ${YOFF:=0} + ${PY:=0}`

usage () {
    echo >&2 "$PN - work on remote host, $VER (stv '95)
usage: $PN [-c] [-l loginname] [host ...]
    or $PN [-c] login@host [login@host ...]
   -c:  check if host is alive (using ping(1))"
    exit 1
}

msg () {
    for i
    do echo "$PN: $i" >&2
    done
}

fatal () { msg "$@"; exit 1; }

PingHost=false
# Check arguments before setting them
getopt chl: "$@" > /dev/null 2>&1    || usage
set -- `getopt hl: "$@"`
while [ $# -gt 0 ]
do
    case "$1" in
        -c)    PingHost=true;;
    -l)    User="$2"; shift;;
    --)    shift; break;;
    -h)    usage;;
    -*)    usage;;
    *)    break;;            # first file name
    esac
    shift
done

isxwindows || fatal "use only with X Windows"

CurHost=`uname -n`
: ${User:=$USER}

[ $# -lt 1 ] && set -- $CurHost

if [ -z "$SSH_AGENT_PID" ]
then Rcmd=rlogin
else Rcmd=ssh
fi

# Give the user time to change to another virtual desktop
sleep 3

# For each host there will be two windows. We handle the following cases:
#  (1) local window
#  (2) remote window
# both cases with (a) current or (b) different user.
# We set the variables
#    o    "cmd" to the command to be run in the window (none, "login", or
#       "$Rcmd")
#    o    "geom_left", "geom_right" to the geometry for the left and right
#       window, respectively

for Host
do
    case "$Host" in
        *@*)
        User=`echo "$Host" | cut -d@ -f1`
        Host=`echo "$Host" | cut -d@ -f2`
        ;;
    esac

    OPTS="$XTERMOPTS -T ${User:+$User@}$Host"

    if [ "$Host" = "$CurHost" ]
    then                # Local work
    if [ "$User" = "${USER:-INVALID}" ]
    then                # (1a) Default user - no login
        cmd=
        geom_left="${DX}x${DY}+${XOFF}+${YOFF}"
        geom_right="${DX}x${DY}+${X}+${YOFF}"
    else                # (1b) User specified - login
        cmd="login \"$User\""
        geom_left="${DX}x${DY}+${XOFF}+${YOFF}"
        geom_right="${DX}x${DY}+${X}+${YOFF}"
    fi
    else                # Remote login
    if [ $PingHost = true ]
    then $PINGONCE "$Host" || continue
    fi
    cmd="$Rcmd ${User:+-l $User} \"$Host\""
    geom_left="${DX}x${DY}+${XOFF}+${YOFF}"
    geom_right="${DX}x${DY}+${X}+${YOFF}"
    fi

    if [ -n "$cmd" ]
    then
    eval $XTERM $OPTS -g $geom_left  '-e "$cmd"' &
    eval $XTERM $OPTS -g $geom_right '-e "$cmd"' &
    else
    eval $XTERM $OPTS -g $geom_left &
    eval $XTERM $OPTS -g $geom_right &
    fi

done

wait
Comments
Add NewSearchRSS
Only registered users can write comments!

Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved.


 

Ultimele comentarii

Tips & Tricks

O arhivare mai buna cu gzip
Daca preferi ca arhivele tale gzip sa fie cat mai bine comprimate, foloseste comanda export GZIP=--best. Data viitoare cand vei arhiva cu gzip, comprimarea va fi facuta la cel mai inalt nivel.
 

Vizitatori Online

Avem 10 vizitatori si 1 membru online

Doneaza pentru un banner MYLRo.org pe Distrowatch

Introdu o suma de macar 5$ (astfel incat suma donata sa fie cu ceva mai mare decat taxa de transfer PayPal) si trimite-mi un mail cu un link catre site-ul tau. Link-ul va fi afisat pe mainpage-ul MYLRo.org si 90% din paginile aferente site-ului pe intreaga perioada a hostarii bannerului de pe DistroWatch.