I am writing a bash script and want to switch to another user, cd into a directory specified by MYDIR in the users bash_profile and list the contents.
Currently I have:
read username
su - app${username} -c ls $MYDIR
The output is nothing, my first guess is that it is a problem reading $MYDIR from the users profile as doing it manually works fine e.g.
#su - appadmin
#ls $MYDIR