User Tools

Site Tools


Site Information

Interactive Maps




With the Ubuntu subshell installed in Windows 10 Home, and IF you've installed sshpass (which doesn't come preinstalled in Ubuntu), then it's possible to SFTP files using a batch file!

There are 3 files in the series:

We begin our journey with the DOS batch file. [Note: I added the prompt and user input just so I could see what was on my screen at the end of the batch. Hey, remove it if it bugs you!]. The 2nd line calls the Ubuntu bash shell from Windows.

@echo off
bash -c ./

REM demonstrate how to get input from user in DOS...
set /p answer=Quit [yes/no]?:
echo "%answer%"

Next comes the Linux bash shell script called from the DOS batch file, above. In this example, the (freshly) installed sshpass starts the sftp session, loging on to using the password password1 and the User ID of me. It also looks for sftp commands in the next file in the series, sftp.cmd.
sshpass -p password1 sftp -oBatchMode=no -b sftp.cmd

In the following SFTP command batch file, SFTP will change directories. On my system, the database files are read-only, so I have to chmod the directories and files. SFTP doesn't understand the "-r" option for chmod, so I have to do it one directory at a time. [Sorry - GeSHi doesn't know ftp or sftp commands, so the syntax highlighting adheres to bash - I like the pretty colors!]. I add a lot of pwd and ls commands so I can see what's happening - remove them if they bug you!

ls -l
chmod 755 gva
cd gva
chmod 755 gva*
ls -l
lcd ../dbs
lls -l
put gva*.db
chmod 555 *
ls -l
cd ..
chmod 555 *
ls -l
wiki/lnx/sftpdos.txt · Last modified: 2019/07/26 04:16 by terrill