[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A Flaw
From: |
SoloCDM |
Subject: |
Re: A Flaw |
Date: |
Fri, 14 Dec 2001 10:23:36 -0700 |
SoloCDM stated the following:
>
> The attached sample (it isn't the entire script) has no problems
> processing as is, but when I remove the comment from "FSCREEN" *or*
> "echo $MFILTER $MFILTER_ANS", it automatically skips "read MANS" and
> accepts the wildcard in the case as the answer for "MFILTER_ANS".
The former attached file is not valid anymore. The presently attached
file is the most correct.
Originally, I had the presently attached file sample as the working
script, then recently I converted it to a function, but found
information was lacking in the process, so it's back to the original
layout.
> When I remove the tabs preceding every line, then the prompt for read
> works, but with "FSCREEN" *and* "echo $MFILTER $MFILTER_ANS"
> uncommented nothing happens to the screen. If I copy down the
> function lines for "FSCREEN" to replace "FSCREEN", nothing happens to
> the screen.
While uncommented, FSCREEN is overriding the read statement and the
echo line preceding read.
I have produced internal script results for the following variables,
as you can see the echo commands for variables aligned to the left of
the script. The first set of four variables, as you can see by the
echoes, are echoed to the screen, which makes the read automatically
echo to the screen but not pause for any input. There is a blank
after MFILTER.
MVOID_FILTER
Y
MANS
/[user_directory]/nsmail/Technical
Support.sbd/Linux.sbd/FWTK.sbd/.Personal.summary
MTYPE
ASCII mail text
MFILTER
The second set of variables are echoed to a file, but the same data is
somehow getting input into the variables without my knowing how.
Although the script stops for the read statement and I'm able to input
a letter to meet the case statement, somehow MANS is initialized by a
file name.
MFILTER
MVOID_FILTER
Y
MANS
/[user_directory]/nsmail/Technical
Support.sbd/Linux.sbd/FWTK.sbd/.Personal.summary
MTYPE
ASCII mail text
I thought the variable names might be too long, so I ran the script
with shorter names and that didn't work. I converted all "[] && {
{list} }" statements to "if [];then {list};fi" statements, but it
didn't work.
I've created very extensive scripts, but nothing like this has ever
happened. Even though I remove the extra brace "{" after the first
call to FSCREEN and the last brace "}" with the semi-colon at the next
to the last line on the end, the script stills behaves in the same
manner.
> This problem can be reproduced; therefore, what is causing the
> problem?
Recently, I found the problem can be reproduced with or without the
tabs preceding every line. But, now I'm running the script as root.
*********************************************************************
Signed,
SoloCDM
FSCREEN () {
clear
echo -e "\n\t Query results will display momentarily"
echo "[-] ************************************************ [-]"
echo;
}
FSCREEN
{
[ -n "${3}" ] && {
find "${MDIR}" -type f -xdev -fstype ext2 \( -iname '*'${3}'*' -o -iname
'.*'${3}'*' \) -print |\
while read MFILE
do
[ -s "${MFILE}" ] && {
MTYPE=`file "${MFILE}" | sed -e 's+^.*:++' -e 's+^[ ]*++g' -e 's+[
]*$++g'`
case "${MTYPE}" in
'ASCII mail text')
[ -z "${MVOID_FILTER}" ] && {
clear
echo
echo -e "\tSearch the H)eader, B)ody, or bO)th? \c"
read MANS
# read -p' Search the h)eader, b)ody, or bo)th?' MANS
# echo
#FSCREEN
case ${MANS} in
h|H)
MFILTER='formail -X "" -ds'
MVOID_FILTER=Y
;;
b|B)
MFILTER='formail -I "" -ds'
MVOID_FILTER=Y
;;
*)
MVOID_FILTER=Y
;;
esac
}
#echo MFILTER
#echo $MFILTER
#echo MVOID_FILTER
#echo $MVOID_FILTER
#echo MANS
#echo $MANS
#echo MTYPE
#echo $MTYPE
#echo MFILTER >> output-sample
#echo $MFILTER >> output-sample
#echo MVOID_FILTER >> output-sample
#echo $MVOID_FILTER >> output-sample
#echo MANS >> output-sample
#echo $MANS >> output-sample
#echo MTYPE >> output-sample
#echo $MTYPE >> output-sample
#echo >> output-sample
#echo >> output-sample
#echo >> output-sample
[ -n "${MFILTER}" ] && {
MFOUND=`${MFILTER} < "${MFILE}" | ${MEGREP} "${2}"`
} || {
MFOUND=`${MEGREP} "${2}" "${MFILE}"`
}
;;
*)
MFOUND=`strings -a "${MFILE}" | ${MEGREP} "${2}"`
;;
esac
[ -n "${MFOUND}" ] && {
echo less +Gg \"${MFILE}\" >> "${MRBIN}find-match-files-${MSUBJECT}"
echo "\"${MFILE}\" \\" >> "${MRBIN}find-match-view-files-${MSUBJECT}"
}
}
done
} || {
find "${MDIR}" -type f -xdev -fstype ext2 -print |\
while read MFILE
do
[ -s "${MFILE}" ] && {
MTYPE=`file "${MFILE}" | sed -e 's+^.*:++' -e 's+^[ ]*++g' -e 's+[
]*$++g'`
case "${MTYPE}" in
'ASCII mail text')
[ -n "${MVOID_FILTER}" ] && {
clear
echo
echo -e "\tSearch the H)eader, B)ody, or bO)th? \c"
read MANS
FSCREEN
case ${MANS} in
h|H)
MFILTER='formail -X "" -ds'
MVOID_FILTER=Y
;;
b|B)
MFILTER='formail -I "" -ds'
MVOID_FILTER=Y
;;
*)
MVOID_FILTER=Y
;;
esac
}
[ -n "${MFILTER}" ] && {
MFOUND=`${MFILTER} < "${MFILE}" | ${MEGREP} "${2}"`
} || {
MFOUND=`${MEGREP} "${2}" "${MFILE}"`
}
;;
*)
MFOUND=`strings -a "${MFILE}" | ${MEGREP} "${2}"`
;;
esac
[ -n "${MFOUND}" ] && {
echo less +Gg \"${MFILE}\" >> "${MRBIN}find-match-files-${MSUBJECT}"
echo "\"${MFILE}\" \\" >> "${MRBIN}find-match-view-files-${MSUBJECT}"
}
}
done
};
}