$ sudo su - user1 -c 'echo $DOMAIN_HOME' /app/user1/DOMAINHOME
This looks fine, right? However, let's dig a little deeper:
$ sudo su - user1 -c 'echo $DOMAIN_HOME' | tee test.out $less test.out ESC]P0000000ESC]P8A9A9A9ESC]P1DC143CESC]P9FF0000ESC]P2008000ESC]PA00FF00ESC]P3aa9943ESC]PBFFD700ESC]P41E90FFESC]PC87CEFAESC]P5706c9aESC]PD826ab1ESC]P6FFA500ESC]PEF0F8FFESC]P7FFFFFFESC]PFFFFFFFESC[HESC[2JESC[HESC[2J/app/user1/DOMAINHOME
This is causing my scripts to fail.
They are color codes that are sourced by .bashrc which is sourcing colors for xterm. After doing a little research, the last section [HESC[2JESC[HESC[2J is what clears the terminal prior to outputting the path.
I've been pulling my hair out trying to figure out why these are showing up. Any Ideas?
Note: When logged in as user1, it echoes the variable just fine.