Not able to execute shell commands after login to remote server using execute script

I’m using execute script to login into the remote server. I’m able to login successfully but after login I’m not able to execute any commands on the remote server like cd, pwd etc

I tried using both .exp and .sh and both has the same problem. Execution stops after execute script.

execute_script.exp file


eval spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no [email protected]****
expect "Password:"
send "passwordr"
send "r"
expect "user"
send "pwdr"

#!/usr/bin/env bash

expect <<- DONE
  set timeout -1

  spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no [email protected]****

  # Look for passwod prompt
  expect "Password:"
  # Send password aka $password
  send -- "password#r"
  # send blank line (r) to make sure we get back to gui
  send -- "r"
  send "pwdr"
  expect eof

This is what happens after .exp script execution. Please advice what mistake I’m doing or let me know for any other approach. My goal is to ssh to the remote server and execute a python script from a certain path

SSDL-231234:common user$ expect execute_script.exp 
spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no [email protected]****
Last login: Sun Sep 15 20:10:19 2019 from ****

Source: StackOverflow