502 error in FTP code

C

CM@POA

I am trying to write a very small program to send a nonstandard command to
some polycom endpoints and I am running into a problem after I get logged in
successfully and try to send the command I get a 502 command not implemented
error (which if i test by hand works fine) it seems like the command I am
sending is getting trashed somehow but I even setup a ftp sever locally to
see what commands are being recieved and it looks like the right command..
BUT I then changed the command to "dir" and "ls" and those both came back
also unimplemented.. so is something getting attached to the end of my
command I am not seeing and breaking it?

Here is a bit of the code

class Program
{
static void Main(string[] args)
{
OpenFTP.FTP f = new OpenFTP.FTP();
f.Connect("127.0.0.1", "loginname", "password");
f.PolycomReboot("dir");

f.Disconnect();
f = null;
}
}
}

(I get connected just fine)

Here is the send command code (used for sending all command including the
login and pw):

internal static void SendCommand(string sCommand)
{
Connect();

Byte[] byCommand = Encoding.ASCII.GetBytes((sCommand + "\r\n").ToCharArray());

main_sock.Send(byCommand, byCommand.Length, 0);
ReadResponse();
}


let me know if you need anymore info.. this is driving me crazy
 
C

CM@POA

Have you tried the FtpWebRequest class in .NET?
You appear to be using a third-party class for your FTP access, which is
really outside the scope of this newsgroup. You'd probably get much
better support in a forum specific to the provider of the OpenFTP class,
or even contacting the authors of that class directly.

Pete

I have not tried that class i'll take a look at it. I'm fairly new to C# so
was trying to go with something "easy" to get done what I need which is
basically a program that will connect to 15 remote polycom units via ftp and
issue a special reboot command on a scheduled basis. This OpenFTP and even
one other example library I found both allow me to connect to the client very
easy but once connected no commands are working. I get 502 errors for even
standard stuff. I installed a copy of Serv-U FTP to see what commands it
see's me sending and they LOOK ok but even on serv-u simple things like dir
are failing.. The OpenFTP is kind of old and I modified it to add the reboot
commands in (but did not change the send code) so I have not tried talking to
the original author. Their send code is pretty much exactly as the other code
I have seen examples of though...

Oh and the code I noticed I left out above for PolycomReboot() just takes
whatever string is sent to it and forwards it to the send process.
 
C

CM@POA

BTW this is not for a web based project so i'm not sure that class would
work? This is a small console based app.
 
C

CM@POA

Ok I took a look at FtpWebRequest and while it certainly makes standard ftp
pretty simple/easy it will sadly not work for me as it won't accept custom
commands/strings. Can anyone point me at some very simple code to simple
connect to a server and send any string to the server and have it respond
correctly without using FtpWebRequest? Even a simple ls/dir will work as I
can replace that with the custom polycom string.. it just can't be a built in
get directory method.. TIA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top