Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flatlinebb/59ac0b5185ee4158ca77261c69c16096 to your computer and use it in GitHub Desktop.
Save flatlinebb/59ac0b5185ee4158ca77261c69c16096 to your computer and use it in GitHub Desktop.
Using psftp to automate tasks from batch file to sftp server
psftp username@sftp.server.com -pw password -noagent -4 -batch -be -b commands.txt > log_file_%date:~10,4%-%date:~7,2%-%date:~4,2%-%time:~0,2%%time:~3,2%%time:~6,2%.txt 2>&1
# log_file_%date:~10,4%-%date:~7,2%-%date:~4,2%-%time:~0,2%%time:~3,2%%time:~6,2%.txt = log file with a timestamp
# -pw = password
# -4 = use IPv4
# -batch = disable all interactive prompts
# -be = don't stop batchfile processing if errors
# -b filename = use specified batchfile
# -noagent = disable use of Pageant
# -bc = output batchfile commands
# commands.txt contain all the psft commands that need to be executed like:
lcd c:\test
cd folder/sub/folder
mget *.gz
del *.gz
mput *.pdf
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment