the task at hand is to have windows batch script, that can connect to an SFTP server, scan certain folders for presence of any file in them. If the file is there, copy it to local machine.
If possible, i would want to avoid installing any external tools, such as WinSCP (however,i would welcome any such suggestions).
I am new to batch scripting (as in i started looking into it today), and would help with suggestions and pointers that i can look into more detail.
For now i am stuck at first step - connecting to an SFTP server
I can do it via command line by typing
sftp <username>@hostname
and enter password when prompted.
But how do i provide password when running a batch script? I want the connection process to be automatic, as soon as batch script runs.
I saw some comments about installing sshpass and then using
sshpass -p YOUR_PASSWORD sftp -oBatchMode=no -b YOUR_COMMAND_FILE_PATH USER@HOST
But other posts called it very un-secure.
I welcome any comments, suggestions, links to read to hep me with this first step. Feel free to post your suggestions on other steps (such as scanning specific folders for a file, etc).
Given i have only few days to accomplish this, i thought i would get pointers at stackexchange, instead of going through whole tutorials and then think about a solution. So if you guys have any ideas, and comments on their pros/cons, i welcome it.