Click to See Complete Forum and Search --> : Bash Script: Quotes in a variable command.


Paasan
01-22-2004, 08:54 AM
I need some help getting
http://62.73.217.42/2.jpg
look like this
http://62.73.217.42/1.jpg

This is the code i've used in the first picture

#!/bin/sh
RULES_FILE="fw-fwd"

function menu_rules() {
i=1

while read LINE
do
var1=$i
var2=$LINE
finalvar="$finalvar \"${var1}\" \"${var2}\""
let "i += 1"
done < $RULES_FILE

dialog --backtitle "Back Title" --title "Title" --inputmenu "" 0 70 10 $finalvar
}

menu_rules

And this is what i used in the second picture

#!/bin/sh
dialog --backtitle "Back Title" --title "Title" --inputmenu "" 0 70 10 \
"1" "any any any any ACCEPT" \
"2" "tcp any 0.0.0.0/0 0.0.0.0/0 DROP"


I cant use the second code since i need it to read from a seperate file like in the first code.

Really hope someone can help, had this problem for quite a while.

If you want to download the script with a modified version of dialog and the fw-fwd file you can get it here: http://62.73.217.42/paasan.tar.gz
it will extract everything to a directory called "paasan" so nothing will mess up your system.

Thanks in advance

jim mcnamara
01-23-2004, 11:42 AM
Here is a start:

#!/bin/sh

RULES_FILE="fw-fwd"
tmp=`cat $RULES_FILE | tr -s '\n' ' ' | tr -s '"' ' ' `
tmp=`echo $tmp| sed -e 's/DROP/DROP:/g' -e 's/ACCEPT/ACCEPT:/g'| tr - s ':' '\n'`
echo "$tmp"