Able to connect to sftp server using GUI but not through batch script

Advertisement

TeeLem
Guest

Able to connect to sftp server using GUI but not through batch script

I am able to connect to an sftp server using the GUI interface, but not using a batch file. I have copied the batch file command lines that are generated from the GUI connection. The password does contain characters that are not accepted by WinSCP, but they are converted in the generated batch script.

I am using WinSCP version 5.13, on a windows computer.

I have attached two log files from each connection attempt. I have modified the personal information contained in the files for privacy (username, hostname, ip, etc)

What could be the issue?

Thank you.
  • UnableToConnect.txt (5.75 KB, Private file)
  • AbleToConnect.txt (6.82 KB, Private file)

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Able to connect to sftp server using GUI but not through batch script

Do you have an access to server logs? What does it show for these two sessions?

Reply with quote

TeeLem
Guest

Re: Able to connect to sftp server using GUI but not through batch script

I do not have access to servers as they are operated by outside clients. However, I can ask them to look at the logs if you tell me what they should be looking for.

Thank you!

Reply with quote

TeeLem
Guest

Re: Able to connect to sftp server using GUI but not through batch script

I found the issue. I am using the script for a batch file which is generated by the GUI. The script converted an & to hex with two %, like this %%26. Apparently, only one % is needed. When I removed the extra %, the batch file worked.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Able to connect to sftp server using GUI but not through batch script

TeeLem wrote:

I found the issue. I am using the script for a batch file which is generated by the GUI. The script converted an & to hex with two %, like this %%26. Apparently, only one % is needed. When I removed the extra %, the batch file worked.
Can you tell us how did you generate that script?
WinSCP uses two %, when generating a batch file only (in a batch file two % are needed). But not when generating a script file - what you are using.
Haven't you copied the open command from a generated batch file into a WinSCP script file?

Reply with quote

Advertisement

TeeLem
Guest

Re: Able to connect to sftp server using GUI but not through batch script

I am generating the code for the batch file within the WinSCP gui - Manage, Generate session URL/code - then I select the Batch File format type. The code the gui provides will include two % when converting the unusable characters in the password. When I run my batch scripts, I only need the one % in the password for the converted characters. Using the two will cause the authentication error.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Able to connect to sftp server using GUI but not through batch script

The code generated for "Batch file" format passes commands to WinSCP on its command-line using /command switch. There, % needs to be doubled. While, as the UnableToConnect.txt log file shows, you are using a WinSCP script specified using /script switch. In a WinSCP script, you do not double the %.

So again, I believe you have copied the open command from a code generated for the "batch file" format into a WinSCP "script file", instead of using a code generated for the "script file" format.

Reply with quote

Advertisement

You can post new topics in this forum