above script is copying file to remote server. send commands are failing.
couldn't read file "766": no such file or directory
How can I get rest of the code after first sleep 1 working? Do I need to initiate another SSH connection? Can I use ssh connection opened for scp and perform other commands?
Note that in your script the 1st argument passed to expect is -c and I have marked the 2nd argument to expect in red. That makes the 3rd argument passed to expect be the string 766 (which appears to be interpreted as a filename by expect thereby producing the diagnostic message you quoted).
If you want to pass quoted strings to commands inside the 2nd argument to expect , you need to escape the inner quotes. Note also that some of the arguments passed to send are quoted and some are not. I would assume that they should be consistently quoted or unquoted; not a mix.