pass the variable through SSH and run commands using the variable

Solution 1:

Add bash to the end of the initial command; ssh_test.sh should look like:

#!/bin/bash
execommand(){
 ssh ${hostname} "application=$app1 bash" <<'EOL'
  echo "$application"
  cd /opts/logs/${application}
EOL
}

source input.txt
execommand

so that your commands are actually processed by the shell. Before, the shell wasn't even receiving them.

If you wish to disable the Pseudo-terminal will not be allocated because stdin is not a terminal. warning that you will see, you may add the -T flag to the ssh command, and modify it like so:

 ssh -T ${hostname} "application=$app1 bash" <<'EOL'