D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Bash: pointers?

 

Simon Williams wrote:
> 
> Anyone know if this sort of thing is possible?

You can use "eval" (see man bash). Although for the example below it is
overkill. It isn't that useful an approach for many problems, unless you
know you can trust the input data. Otherwise something like Perl, with
"Taint", "system" and friends is a better approach.


#!/bin/sh

eth0="echo hello"
eth1="echo world"

for device in \$eth0 \$eth1
do
 echo device is $device
 eval $device
done

Attachment: signature.asc
Description: OpenPGP digital signature

-- 
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html