Saving Env Variable as a file using SFTP

Advertisement

Ikeuchi
Joined:
Posts:
2
Location:
London

Saving Env Variable as a file using SFTP

Hi all,
I have been reading about /stdin and /stdout but could not find the answer.
I have an env variable, and I want to save it as a text in the SFTP. It would be the equivalent of the command:
echo %tfile% > new.txt
Here is the script structure:
set tfile="I want this as a text file in the server"
winscp  /log="C:\sftp\logwinscp.log" /ini=nul /command ^
   "open sftp://user@site.files.com/ -hostkey=""ssh-rsa 4096 xxxxxxxxxxxxxcvvieGg1R2Vx8/5VSw="" -privatekey=""C:\sftp\private.ppk""" ^
   "put ????? new.txt" ^
   "exit"
For particular reasons, I want to avoid saving a local file before uploading it.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: Saving Env Variable as a file using SFTP

set tfile="I want this as a text file in the server"
echo %tfile% | winscp /stdin /log="C:\sftp\logwinscp.log" /ini=nul /command ^
   "open sftp://user@site.files.com/ -hostkey=""ssh-rsa 4096 xxxxxxxxxxxxxcvvieGg1R2Vx8/5VSw="" -privatekey=""C:\sftp\private.ppk""" ^
   "put - new.txt" ^
   "exit"
See https://winscp.net/eng/docs/commandline#stdin
https://winscp.net/eng/docs/scriptcommand_put#stream
Last edited by martin on 2021-08-13; edited 1 time in total

Reply with quote

Advertisement

You can post new topics in this forum