Scripting...
Jan. 29th, 2004 10:01 amsomeone sent me this script:
saying that it doesn't work... well, no, it doesn't... What is being done isn't an easy thing, shell pointers are a pain.. this is how it should be written
I don't think this is what he wants but it matches what he listed in the one he sent me...
this is what I think he wants:
looks a little bit simpler, prints out the name and the service on each line... we will see...
comments?
#!/bin/bash
COMPUTERS="$SQLSERVICES $MAILSERVICES $PHONESERVICES"
SQLSERVICES="80 8080"
MAILSERVICES="110 25 143"
PHONESERVICES="53 4569 5036 5060"
for x in ${COMPUTERS}; do
echo ${x} #Should echo the current service list
for y in ${x}; do
echo ${y} #Should echo the ports in $x
done
done
saying that it doesn't work... well, no, it doesn't... What is being done isn't an easy thing, shell pointers are a pain.. this is how it should be written
#!/bin/bash
SQLSERVICES="80 8080"
MAILSERVICES="110 25 143"
PHONESERVICES="53 4569 5036 5060"
COMPUTERS="SQLSERVICES MAILSERVICES PHONESERVICES"
for x in ${COMPUTERS}; do
echo ${x} #Should echo the current service list
for y in ${x}; do
POINTER="echo \$"$y
eval $POINTER #Should echo the ports in $x
done
done
I don't think this is what he wants but it matches what he listed in the one he sent me...
this is what I think he wants:
#!/bin/bash
SQLSERVICES="80 8080"
MAILSERVICES="110 25 143"
PHONESERVICES="53 4569 5036 5060"
COMPUTERS="SQLSERVICES MAILSERVICES PHONESERVICES"
for x in ${COMPUTERS}; do
POINTER="echo \$"$x
for y in `eval $POINTER`; do
echo ${x} ${y} #Should echo the current service list
done
done
looks a little bit simpler, prints out the name and the service on each line... we will see...
comments?