Eric Wolzak wrote:

<snip>

#
But now I found a bug :(
#

<snip>


# change
#
# evaluate returnnames to local names
#
# As I use uncgi the fieldnames are returnde as $WWW_name
# This is probably unneccessary.
# The problem is however the name$nr
#
# ---------------------------------------------------------
# Those are the troublesome lines # -------------------------------------------------------
#
eval name="\$WWW_name$nr"
eval ip="\$WWW_ip$nr"
#
# -----------------------------------------------------------------------------
# this functions good unless name1 2 etc. contains a special char
# for example "*" # the eval function will find a filename for it and not just write it to the
# database
# the same trouble could probably be caused by backticks in a name
# any suggestion to improve this ? #
# or in other words how can I evaluate a number of numbered fieldnames without # evaluating the contents.
#
#-------------------------------------------------------------------------------

Are you sure you have a problem? This works for me in both bash and ash shells on Dachstein:


Ash:
tempest: -root-
# name1="*.*" ; x=1

tempest: -root-
# eval z="\$name$x"

tempest: -root-
# echo "name1: $name1" ; echo "z: $z"
name1: *.*
z: *.*

Bash:
tempest: -root-
# name1="*.*" ; x=1

tempest: -root-
#  eval z="\$name$x"

tempest: -root-
# echo "name1: $name1" ; echo "z: $z"
name1: *.*
z: *.*

#
# test if the first or obligate field is empty
#
if [ -n "$name" ]; then
#
#
# write the row
# option that can be empty are set in their own line
#
$cdb set tree $tree/$ct name $name ip $ip

I think this is your problem...using the above hand-entered test code, follow up with:


tempest: -root-
# echo "$name1"
*.*

tempest: -root-
# echo $name1
POSIXness.conf ae.rc checksecurity.conf cron.d cron.daily cron.monthly cron.weekly dhcpd.conf host.conf hosts.allow hosts.deny hosts.equiv inetd.conf init.d ioctl.save ipchains.forward ipfilter.conf ipsec.conf ipsec.secrets issue.net login.access lrp.conf minirc.dfl network.conf nsswitch.conf pcnfsd.conf ramdisk.conf rc.boot rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rcS.d resolv.conf snmpd.agentinfo snmpd.conf syslog.conf


What happens if you try:
$cdb set tree $tree/$ct name "$name" ip "$ip"

Thanks for any help

No problem...getting quotes in the proper place can be tricky sometimes in shell script.


You might want to checkout the ash man page (easier to comprehend than the much larger bash man page), starting with the "Word Expansions" topic, which covers expansion order and goes on to detail exactly how arguments are processed. You might also find the "set -x" command handy, which will dump the actual command the shell runs after various word expansions have occured) to err-out...a handy debugging tool for shell code.

Handy ash man page link:
http://www.leaf-project.org/devel/cstein/Documentation/ash.html

--
Charles Steinkuehler
[EMAIL PROTECTED]




------------------------------------------------------- This SF.net email is sponsored by: SF.net Giveback Program. SourceForge.net hosts over 70,000 Open Source Projects. See the people who have HELPED US provide better services: Click here: http://sourceforge.net/supporters.php

_______________________________________________
leaf-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/leaf-devel

Reply via email to