Unix shells: How to ensure command works against most common shells?

I have some java code which uses jsch to connect to our unix servers and run below command. ls -lt /tempdirectory/ grep -v ‘^do | grep “$”(date ‘+%b %e’)” | head -1 | awk ‘{print %9}’ …

My JSch session doesn’t execute command

I’m trying to write a Java code that can ssh into a Unix server and reset a user’s password. So I tried to implement some of the code found in SO. Eg. Sending commands to remote server through ssh …