[plug] Bash "Processing" Script

Jay Turner jturner at bsis.com.au
Fri Jun 11 12:19:56 WST 2004


> Hi All,
>
> I have written a bash script that I can use to image partitions from one
> disk to another using 'dd'.
>
> As this process can take a while and 'dd' doesn't offer any processing
> information, I was hoping to
> output a '.' to the screen every x seconds while 'dd' does it's thing.
> ie
>
> Imaging............
>
> With a new dot appearing after x seconds.
>
> Does anyone have any ideas on the best way to do this?

As usual, two minutes after I press send, I finally find something after an
hour of searching.

I found the following stop function in Squid's init.d script.
It looks like it can do what I need, I am just having some problems
understanding it..

The portion I think i am interested in I have highlighted for your viewing
pleasure.
Can someone please describe to me the process that occurs here, in
particular, what "while : ;" does.. I think
that might be the key I am looking for.

Thanks
Jay

stop() {
    echo -n  $"Stopping $prog: "
    $SQUID -k check >/dev/null 2>&1
    RETVAL=$?
    if [ $RETVAL -eq 0 ] ; then
        $SQUID -k shutdown &
        rm -f /var/lock/subsys/$SQUID

========= Start here ============
	timeout=0
	while : ; do
        [ -f /var/run/squid.pid ] || break
        if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
            echo
            return 1
        fi
        sleep 2 && echo -n "."
        timeout=$((timeout+2))
        done
========== End here? ===========

    echo_success
    echo
    else
        echo_failure
    echo
    fi

    return $RETVAL
}





More information about the plug mailing list