X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=software%2Funix%2Fbringup.sh;fp=software%2Funix%2Fbringup.sh;h=efc87392f496ac1d7c6ee533002d1886b75c92a7;hb=80ef9a31a67d47857199502734a95700aae707ea;hp=0000000000000000000000000000000000000000;hpb=86ea87513c4c66ebfee8ef2a887730aaef65a82d;p=sites%2Fhome_page.git diff --git a/software/unix/bringup.sh b/software/unix/bringup.sh new file mode 100644 index 0000000..efc8739 --- /dev/null +++ b/software/unix/bringup.sh @@ -0,0 +1,38 @@ +#!/bin/sh +TITLE="$1" +shift +COMMAND=$1 + +ttyprefix=/dev/; #for linux systems with /dev/pts +cmdcolumn=5 ;# where to find command in ps output +ttycolumn=2 ;# where to find tty name in ps output +psargs=aww; +get_tty_from_command () { + local t + t=`ps $psargs|awk "\\$$cmdcolumn~/$1/ {print \"$ttyprefix\" \\$$ttycolumn;exit}"` + if [ -z "$t" ] + then + return 1 + fi + check_tty $t +} + +check_tty () { + if [ ! -c $1 ] + then + echo "$i is not valid tty name" >&2 + exit 1 + fi + if [ ! -w $1 ] + then + echo "$i is not writable for you" >&2 + exit 1 + fi + tty=$1 +} + +if get_tty_from_command $COMMAND; then + echo -n '' >$tty +else + xterm -T "$TITLE" -name $COMMAND -e "$@" & +fi