It seems to me that aliases cannot be inherited from the environment into shell scripts. However you can use aliases in a shell script if the alias definition is in your $HOME/.bashrc file and if you make your shell act as a login shell (in this case the .bashrc file is sourced). For example
Code:
#!/bin/bash -l
shopt -s expand_aliases
var2=$(temp | awk '{print $4}')
echo $var2
In the first line you have to add the -l option to bash. Furthermore the second line uses the shopt command to enable the expand_aliases option, otherwise aliases are not interpreted. Anyway there are a lot of reasons to not use aliases inside scripts and use functions instead. See Chapter 24 of the Advanced Bash Scripting Guide for a full treatment.