+1 vote
by (160 points)
edited

I have a need to send site commands to allocate an mainframe dataset, how can I do that using the SFTP product? I don't see any methods or properties that I can set in order to accomplish this task.

I need to be able to send the following command:

QUOTE SITE RECFM=FB LRECL=100 BLOCKSIZE=27900

Any help would be appreciated.

Thanks in advance.

Applies to: Rebex FTP/SSL, Rebex SFTP

1 Answer

0 votes
by (13.3k points)
edited by
 
Best answer

The QUOTE SITE sequence is used in FTP and FTP/SSL clients for sending commands to the server. I don't recall any SFTP server which uses them. Are you sure that you are using the SFTP?

For differences between SFTP, FTPS, FTP and FTP/SSL see www.rebex.net/kb/secure-ftp

Using QUOTE command in FTP/SSL

Following code demonstrates how to use SITE command using Rebex FTP:

// create client and connect 
Ftp client = new Ftp();
client.Connect("ftp.example.org");
client.Login("username", "password");

// send SITE command
// note that QUOTE and SITE are ommited. QUOTE is command line ftp syntax only.
client.Site("RECFM=FB LRECL=100 BLOCKSIZE=27900");

// disconnect 
client.Disconnect();

Sending commands via SSH/SFTP

If you are using SFTP client you can achieve similar functionality by using ssh RunCommand from Rebex Terminal Emulation component. You can connect using SFTP and then reuse the session for sending the command.

// establish the shared SSH connection
var session = new Rebex.Net.SshSession();
session.Connect(hostname);
session.Authenticate(username, password);

// bind an SFTP client to the SSH session
Sftp sftp = new Sftp();
sftp.Bind(session);

// bind an SSH client to the SSH session
Ssh ssh = new Ssh();
ssh.Bind(session);

// execute a simple command
string response = ssh.RunCommand("echo Hello world!");

session.Disconnect();

More info:

...