Assuming that the shell for user@machine_B is bash, the first example 'ssh user@machine_B_adress '. script.sh', bash sets up the shell env differently for interactive/non-interactive sessions.
See man bash about interactive shells
Looks like you can emulate the interactive environment by adding a bash -l -c
$ ssh user@machine_B_address "bash -l -c '. script.sh'
My quick test, I added debug echo to .bash_profile of the remote user
$ ssh foouser@jdsrpi1 "bash --login -c '. foo.sh'"
This is file .bash_profile
foouser
SHELL = /bin/bash
PATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
Similar scenario for ksh
$ ssh [email protected] "date"
Tue Apr 18 11:52:43 EDT 2017
$ ssh kshuser@jdsdrop1 "ksh -l -c date"
This is SHELL(/usr/bin/ksh) file .profile
Tue Apr 18 11:53:24 EDT 2017
which sqlplusps -ef | grep $$ | grep -v grepandecho "$PATH"and also all 3 asssh user@machine_B_adress 'which sqlplus'?