Re: dialog - absolute beginner problems

From: Chris F.A. Johnson (cfajohnson_at_gmail.com)
Date: 10/11/05


Date: Tue, 11 Oct 2005 17:03:31 -0400

On 2005-10-11, darkknight56 wrote:
> Here -
>
> #!/usr/bin/sh
>
> mac()
> {
> count=0
> while read aps
> do
> if [ $count -le $aps ]
> then
> # `dialog --nocancel --backtitle "Network" --title "APs"
> --max-input 17 --clear --inputbox "\nMAC " 10 40 "$mac" > me
> nuitems/mac.txt`
> macnumber=mac${count}
> mac=`cat menuitems/mac.txt`
> count=$ [ $count+1 ]
> rm menuitems/mac.txt
> return #NOTE: Once you enter this if statement, you exit this
> function. No more read from the aps.txt file is done.
> fi
> done < ./menuitems/aps.txt
> }
>
> mac
>
> exit 0
>
> This will work in both Korn and Borne shells. See my previous post,
> though, regarding the 2> and the return statement.

   It might have worked before Google groups mangled it. Please, if
   you must use GG, make sure the lines are short enough so that they
   do not get split by the broken Google interface.

   It will not work in a Bourne shell, even without the line problems
   because a Bourne shell does not do arithmetic. It will not work in
   many POSIX shells because you use a non-standard arithmetic syntax.
   In fact, it doesn't even work in a Korn shell. It should be:

count=$(( $count + 1 ))

   You have commented out the dialog command, which means that there
   will be no file called menuitems/mac.txt, and you'll get an error
   when you try to cat it.

-- 
    Chris F.A. Johnson                     <http://cfaj.freeshell.org>
    ==================================================================
    Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress
    <http://www.torfree.net/~chris/books/cfaj/ssr.html>