Re: how can a executing bash script be paused?



On Dec 17, 9:25 pm, Barry Margolin <bar...@xxxxxxxxxxxx> wrote:
In article
<b7812cb6-087e-48c0-8dda-e405433be...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
 Lao Ming <laoming...@xxxxxxxxx> wrote:



Is there something unusual about pausing a bash script?
I admit that I haven't done any interactive input since I started
using bash.  I want to use 'read' from stdin in order to
slow down a loop when doing:

   bash -x script

I tried:

while [ condition ] ; do
    processing ...
    printf "%s" "Pause: "
    read mypause
done

Thanks.
but it doesn't work.

It looks like it should work.  Could you be more specific than "doesn't
work"?


Well, this is the script that I am trying to debug. It's a small
script
and does only one thing. It collects the first character of each
filename
(excluding dot files) and places the char into an array (if it doesn't
exist
in the array already). The script does not produce output as it is
right now.

#! /bin/bash -f

check_filename()
{
filename="${FILE##*/}"
if [ "${filename:0:1}" = "." ] ; then
FLAG="true"
else
if [ "$INDEX" != "$PREVIOUS_INDEX" ] ; then
INDEX_ARRAY[$I]=$( echo "${filename:0:1}" |tr '[a-z]' '[A-
Z]' )
(( I++ ))
fi
fi
export INDEX_ARRAY
}


declare -a INDEX_ARRAY
PREVIOUS_INDEX=""
INDEX="0"
I=0
find . -type f -name "[0-z]*" |sort -f |
{
while IFS= read -r FILE ; do
FLAG="false"
INCOMPLETE=$( echo "$FILE" |sed 's/^.\///' ) # remove ^"./"
SLASH=$( echo "$INCOMPLETE" |grep '/' )
if [ "$SLASH" != "" ] ; then
dirspec="${INCOMPLETE%/*}"
#else
# check_filename
# [ "$FLAG" = "true" ] && continue
#fi
#if [ "$dirspec" != "" ] ; then
dirname="${dirspec##*/}"
if [ "$dirname" != "" ] ; then
[ "${dirname:0:1}" = "." ] && continue
else
check_filename
[ "$FLAG" = "true" ] && continue
fi
else
check_filename # new
[ "$FLAG" = "true" ] && continue # new
#filename="${FILE##*/}"
#[ "${filename:0:1}" = "." ] && continue
fi
PREVIOUS_INDEX="$INDEX"
done
echo "${INDEX_ARRAY[@]}"
}

.



Relevant Pages

  • Re: BinaryStream.Write ByteArray erroring with Code 800A0BB9, Source ADODB.Stream
    ... script is reaching out to a SQLServer database and grabbing some data ... BinaryStream.Write method expects a byte array, ...     Else ... I made the changes to the script using your code, ...
    (microsoft.public.scripting.vbscript)
  • Re: scripting newb
    ... I was able to hobble this together from another script posted by Dan ... Dim strSearch, strAdsPath, strServerName 'from search script ...     'Prompt for search criteria ... computerName, samAccountName, givenName, sn, AdsPath ...
    (microsoft.public.scripting.vbscript)
  • Re: finding files
    ... I'm back and also my script as changed ever since. ... have to be an Array then.. ... For Each strComputer In arrComputers ...     Function ReadTxtToArray ...
    (microsoft.public.scripting.vbscript)
  • Re: [9fans] `mk` (from Plan9 ports) efficiency related issue
    ...    I'm afraid I don't understand the question. ... script instead of writing the `mk` script myself by hand? ... generator to produce a mk include file with the meta rules plus the mk file ... between multiple projects or libraries each with it's own `mk` script; ...
    (comp.os.plan9)
  • Re: 2 scripts w errors on compacting access db
    ... Script 1: ... This old newsgroup thread included code to compact an Access database: ... ' You must provide a path to the Access MDB which will be compacted ...     On Error GoTo 0 ...
    (microsoft.public.scripting.vbscript)