#!/bin/bash echo "Reading config...." >&2 source /etc/cool.cfg echo "Config for the username: $cool_username" >&2 echo "Config for the target host: $cool_host" >&2So, where do these variables come from? If everything works fine, they are defined in /etc/cool.cfg which is a file that's sourced into the current script or shell. Note that this is not the same as executing this file as a script! The sourced file most likely contains something like:
cool_username="guest" cool_host="foo.example.com"These are normal statements understood by Bash, nothing special to do. Of course (and that is a big disadvantage under normal circumstances) the sourced file can contain everything that Bash understands, including evil code!
Src/more: http://wiki.bash-hackers.org/howto/conffile
No comments:
Post a Comment