Fix home directory expansion bug in automated.sh