Topic "Issue with the code"

Author Message
aman.jboy@...

Guest


Hi,

I am trying to put the zip file from my system to sftp server using the following code.
Most of the information like sftpusername , sftppassword etc are self-explanatory. In case any information is required feel free to ask
But it is failing more often then not I am using WinSCP version 5.9.2 (build 6958). I am using the code below in C#.
The issue occurs when the WinSCP is not able to connect in 15 seconds. After that when it tries to it takes dir, ls as inputs for username and password rather than sftpusername and sftppassword.
winscp.StandardInput.WriteLine(sftpUsername);
//Console.WriteLine("Password: ----->" + sftppassword);
winscp.StandardInput.WriteLine(sftppassword);
// winscp.StandardInput.WriteLine("-hostkey=" +hostkey);
winscp.StandardInput.WriteLine("dir");
winscp.StandardInput.WriteLine("ls");
// Creating directories if not already present
winscp.StandardInput.WriteLine("mkdir " + path);
// Traversing to the required directory
winscp.StandardInput.WriteLine("cd " + path);
//Putting the zip file onto the server
winscp.StandardInput.WriteLine("put " + zippath);
winscp.StandardInput.Close();
string output = winscp.StandardOutput.ReadToEnd();
LogMessageToFile(output);
// completly shutting down the process
winscp.WaitForExit();

The attach log has the issue captured.

Is there a possibility to make it more robust and user-friendly.
Let me know in case any further details or information is required.

Thanks in Advance
WinSCP log.txt (5.08 KB) Private file

Description: logs for the winscp code

martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26150
Location: Prague, Czechia
Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.

Though, you should use WinSCP .NET assembly instead:
https://winscp.net/eng/docs/library
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License