K.S. Bhaskar on 21 Apr 2010 09:46:26 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Shell scripting?


It's a little harder than that writing scripts that must run robustly
on a wide variety of UNIX/Linux environments.  Here's an abstraction
of bits pulled from a script I wrote recently.

-- Bhaskar

-----------------------------------------------------------------------------------------
$ cat /tmp/temp.tmp
#!/bin/sh
trap 'stty sane ; exit 1' HUP INT QUIT TERM TRAP

# echo and options
ECHO=/bin/echo
ECHO_OPTIONS=""
#Linux honors escape sequence only when run with -e
if [ "Linux" = "`uname -s`" ] ; then ECHO_OPTIONS="-e" ; fi

unset tmp
while [ "Y" != "$tmp" ] ; do
    $ECHO $ECHO_OPTIONS "Please indicate interest in shell scripting
(y/n/[?]):" \\c
    read tmp ; tmp=`$ECHO $tmp | tr yesno YESNO`
    case $tmp in
    "Y"|"YE"|"YES") $ECHO "OK, let's get you signed in..."
            tmp="Y" ;;
    "N"|"NO") $ECHO "OK, then join us for libations after the meeting."
            exit 1 ;;
     *) $ECHO
            $ECHO "Answer Y[es] or N[o]"
            $ECHO "This is an example from a shell script that must run"
            $ECHO "robustly on many UNIX/Linux systems."
            $ECHO ;;
    esac
done
unset tmp
-----------------------------------------------------------------------------------------


On Wed, Apr 21, 2010 at 9:01 AM, Carl Johnson
<cjohnson19791979@gmail.com> wrote:
> #!/bin/sh
> echo is anyone interested in shellscripting?
> echo choose y or n \c
> read wish
> echo
> if [$wish = "n"] ; then
> echo cool, you know this stuff then. bye
> exit
>
> if [$wish = "y"] ; then
> echo cool hope to see you at the meeting then. bye.
> exit
>
>
>
>
> Sent from my Treo™ wireless handheld device.
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug