This is a very basic question I am just quite new to bash and couldn't figure out how to do this. Googling unfortunately didn't get me anywhere.My goal is to connect with sftp to a server, upload a file, and then disconnect.I have the following script:UpdateJar.sh#!/bin/bashsftp -oPort=23 kalenpw@184.155.136.254:/home/kalenpw/TestWorld/plugins#Change directory on server#cd /home/kalenpw/TestWorld/plugins#Upload fileput /home/kalenpw/.m2/repository/com/Khalidor/TestPlugin/0.0.1-SNAPSHOT/TestPlugin-0.0.1-SNAPSHOT.jarexitthe issue is, this script will establish an sftp connection and then do nothing. Once I manually type exit in connection it tries to execute the put command but because the sftp session has been closed it just says put: command not found.How can I get this to work properly?Thanks
Execute command in sftp connection through script
ssh;scripting;file copy;sftp
You can change your script to pass commands in a here-document, e.g.,#!/bin/bashsftp -oPort=23 kalenpw@184.155.136.254:/home/kalenpw/TestWorld/plugins <<EOFput /home/kalenpw/.m2/repository/com/Khalidor/TestPlugin/0.0.1-SNAPSHOT/TestPlugin-0.0.1-SNAPSHOT.jar   exitEOFThe << marker followed by the name (EOF) tells the script to pass the following lines until the name is found at the beginning of the line (by itself).