You must put the remote command in quotes, so the local shell sees a string.
E.g. in double-quotes so "$var" is substituted in the string (on the local host).
I'd like to execute .profile as well as i need this variable ${AppsPass} value to be substituted variables dynamically but the below code is not executing it properly.
You might be better to have a script on the target server that:-
Calls .profile
Executes the command
That way, your ssh is kept neater. Is this an option, or will there be a wide variety of calls, of which this is a test case, and you might want to repeat it for many other target servers.
It's all in the quoting to make sure that the right shell evaluates the variables.
What errors are you getting back?
Can you simplify the ssh call to just display what would be executed so you can see what is getting passed where, and as what value?
Yes,I'm calling .profile and executing ssh command in one line but as per my experience i've to include .profile in single quotes only then it works but otherway around in dobule quotes variables are not getting expanded because of single quotes.
I've tried even simpler. As i said above problem with single quotes and double quotes