Issue with using PassPhrase

Advertisement

Swindellvc
Guest

Issue with using PassPhrase

I'm trying to create my first batch script and I'm having issues...that I will deal with one at a time.
My Script looks like this... (I've changed sometimes of security)

@echo off

"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="P:\TK20FileInfo\WinSCP.log" /ini=nul ^
/command ^
"open sftp://cofcit:MayKey@huwey.tk20.com/ -hostkey=""ssh-Classified"" -privatekey=""P:\TK20FileInfo\TK20PRI.ppk""-passphrase=""Music"^
"lcd T:" ^
"cd /home/cofcit" ^
"put tk20_StudentTranscriptfile.txt" ^
"put tk20_StudentTestfile.txt" ^
"put tk20_StudentTablefile.txt" ^
"exit"

set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)

exit /b %WINSCP_RESULT%

The first issues I had is that the file had prompted for the passphrase..but I saw that I could included it in the open line.
the documentation on the actual syntax didn't include an example so I took a stab at it...it doesn't work.
what is the actual syntax.

The second issue I had. (before I tried to include the passphrase) was after it connected is that the script stopped executing right after "LCD T:"^ and the command window leaves me at a prompt.

any and all help appreciated.


Victor
Swindellvc@cofc.edu

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
27,253
Location:
Prague, Czechia

Re: Issue with using PassPhrase

Both your problems have the same cause.
The syntax of the line with the open command should be:
"open sftp://cofcit:MayKey@huwey.tk20.com/ -hostkey=""ssh-Classified"" -privatekey=""P:\TK20FileInfo\TK20PRI.ppk"" -passphrase=""Music""" ^
(also note the space before -passphrase)
See https://winscp.net/eng/docs/commandline#syntax

Reply with quote

Advertisement

You can post new topics in this forum