I'm attempting to run a sequence of commands over SSH. This answer inspired me to use EOF which seemed to work fine at first, but started acting up once I tried running subshell commands using $().
Anyone understand why this:
#!/bin/bash
ssh -o StrictHostKeyChecking=no -tt abcdef@zxcv.net << EOF
cd "$(ls -td -- ~/www/builds/* | head -n 1)"
pwd
composer install
npm run installation
npm run clean
npm run build
exit
EOF
Does this?
17-May-2019 10:29:26 Last login: Fri May 17 12:28:44 2019 from 82.148.198.138
17-May-2019 10:29:26
17-May-2019 10:29:26 cd ""
17-May-2019 10:29:26 pwd
17-May-2019 10:29:26 composer install
17-May-2019 10:29:26 npm run installation
17-May-2019 10:29:26 npm run clean
17-May-2019 10:29:26 npm run build
17-May-2019 10:29:26 exit
The subshell returns blank when executed from a shell script, but works fine when executing it manually in a bash terminal. This happens without the double quotes as well.
I'm doing this on a Ubuntu server.