Well, when you set an environment variable, it lives in the current environment. The current environment is actually the script being executed. If you create a script foobar.sh that set foo to bar and print it like that:
in the life of the script, foo's value is bar. But as soon as you exit the script, foo is undefined, because it only lives in the script. Try it like that:
$ echo foo
foo is no more defined after the script. It isn't even defined in the scripts being called by foobar.sh. For that you have to export the variable like that:
it means that foo lives inside the subscripts of foobar.sh, but not in the script calling foobar.sh
Now, when you use the dot (.) to launch a script, you are actually telling bash to include the script as if you typed the whole script in the current environment. It means that the variables defined by the script will be available after the script has exited (it does not really exit actually.
You can see it like that:
$ . ./foobar.sh
$ echo $foo
foobar.sh has been executed in the current environment instead of creating a child environment for itself.
I hope this clears things up.
About the script changing the wallpapers being called by cron, you have to know that cron does not setup any environment. Your profile is not called and therefore no environment variable is available from your profile. You have to set the environment yourself. Obviously, gconftool-2 uses some variables from your environment in Ubuntu 9.10, although I don't know which. You can find them with ltrace, or with the documentation if it is documented, or just by removing them from the script and see what happened (remove half of them until you find the one that is needed)
About your 2nd question, you can use the tail command to extract the last line of text from any command (cat is the command you need in your case)
cat file.txt | tail -1
This means show the content of file.txt (cat file.txt) and extract the last line (tail -1)