Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

@AndresGomez: And does it work in any other SFTP client for you? For example in the command-line OpenSSH sftp? Show us.
Andres Gomez

Hi, I have this problem,
Error listing directory '/+lrecl=35'.
The file path does not exist or is invalid.

// Setup session options
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Sftp,
    HostName = "10.0.0.7",
    PortNumber = 2222,
    UserName = "user",
    Password = "password",
    SshHostKeyFingerprint = "ssh-rsa 2048 JEdoyPd09IwNgLHT6mnRJunJwO6GihiHhrTgq0TXrks"
};
 
using (Session session = new Session())
{
    // Connect
    session.Open(sessionOptions);
 
    // Upload files
 
    TransferOptions transferOptions = new TransferOptions
    { TransferMode = TransferMode.Automatic, };
 
    session.ListDirectory("/+lrecl=35");
    session.PutFiles(@"C:\Temp\LOTE1808.035", "/public/test2/", false, transferOptions).Check();
}
Ankitakha

Hi I found the solution and its working fine for me.

I used
session.ListDirectory("/+recfm=fb,lrecl=2214,blksize=0,replace/");

to create file with record length of 2214 in mainframe. I am not getting "Cannot overwrite remote file "FineName".$$" error when I used /replace in session.ListDirectory().
Guest

Attached log file as private.
martin

Please attach a full session log file showing the problem (using the latest version of WinSCP).

To generate the session log file, set Session.SessionLogPath. 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.
Guest

Hi Tried using this but getting error.
Cannot overwrite remote file "FineName".$$
Press 'Delete' to delete the file and create new one instead of overwriting it.$$
And also, even after error, it is creating file on server but with no data.

Below is the code that I used.
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Sftp,
    HostName = "ServeName",
    UserName = "Userid",
    SshHostKeyFingerprint = "------------",
    SshPrivateKeyPath = @"----------------",
};
sessionOptions.AddRawSettings("FSProtocol", "2");
sessionOptions.AddRawSettings("CacheDirectories", "0");
sessionOptions.AddRawSettings("CacheDirectoryChanges", "0");
 
using (Session session = new Session())
{
    session.Open(sessionOptions);
    TransferOptions transferOptions = new TransferOptions
    { TransferMode = TransferMode.Automatic, };
 
    session.ListDirectory("/+lrecl=35");
    session.ListDirectory("/+RECFM=FB");
    session.PutFiles(sourcepath, cpedFilename, false, transferOptions).Check();
}


If I am removing
session.ListDirectory("/+lrecl=35");
session.ListDirectory("/+RECFM=FB");

then it is creating file with data but of record length 128.

Let me know if I am doing anything wrong.
martin

You can use:
session.ListDirectory("/+lrecl=255")
Ankitakha

I see that in command we can specify it as:
sftp> ls /+lrecl=255

But in .NET assembly code I am not getting how to specify.
Ankitakha

Hi, Thanks for replying. While using FTP protocol, I didn't specify any record length. At my end length of record is 2214 and while doing session.put() record length is same. But when I am using SFTP protocol, my line is breaking at 100 length and going to next line. Not sure if I have to set any attribute?
martin

Re: specify record lenth while sftp to mainframe in .net code

There's no "record length" in SFTP. If your mainframe SFTP server supports that, it must be some kind of a hack or a proprietary feature. If you provide us any documentation about that, we can help you with setting it up in WinSCP. Are you able to specify the record length in any other SFTP client?
Ankitakha

Specify record length while sftp to mainframe in .NET code

Hi, I am transferring file to mainframe server using WinSCP SFTP .NET code. I have to specify record length while transferring file. At my end record length is 2214 but when I am transferring file it is creating file with 100 length. I tried all transfer modes ASCII, Automatic and Binary. When I was using FTP protocol with ASCII, it used to create file with same record length of 2214. But with SFTP I am facing this issue.