ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
Bots and FTP? (Sdk)
Bots and FTP? // SdkjoshDec 4, 1998, 2:22am
Hello all,
I was wondering if there is a way to make the bot use a ftp server and log to a file on that server, if so can I get some sample code? edward sumerfieldDec 4, 1998, 11:44am
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html> When you say "log to a file" I assume you mean write to it? FTP allows you to move entire files between machines. It doesn't supply a file read/write interface. <p>If you want to log to a local file then move it to another machine that would be possible. I know that MFC has an FTP class that should allow you to do this. Though you should wait for Walter to give you the details. <p>If you are in a Windows environment you can also do this by logging to a local file and then copying the file into a shared directory. This allows a fairly fast logging mechanism and a simple file move. If your server is Lynx then Samba is a product that allows disk sharing with windows using the NFS protocols. <p>If you really want to write to a file on a remote machine then I would suggest one of the following: <p>1. Again, in a windows environment, a simple solution would be to share the remote directory onto the logging machine. It would not be too much of an overhead to log to a file on the remote disk. Keep in mind that these write operations will be blocking operations and that a write to a network drive will be much slower than a write to a local file. The delay added to you logger will depend on how much you want to write to the file. <p>2. Another solution would be to write a little logging server that listens on some socket, receives connections and writes anything that is sent to it to a local file. Then your logger would just have to connect to the log server at startup and write log messages to it. Less overhead than a network disk but still some overhead. <p>3. The most efficient central logging design involves a proxy log server that runs on the local machine. This proxy logger would receive log messages from from processes on the same machine. It would be responsible for forwarding them to a remote, central logging server. This design decouples the time critical logger application from the non time critical logging of messages operation. Ideally some shared memory message exchange should be devised between the logger and the proxy log server for optimum speed. <p>I feel that I have said too much. <p>Edward Sumerfield. [View Quote] joshDec 4, 1998, 9:15pm
What about having the program download the log off the FPT server than
writing to it an when you complete a session it uploads the log to the server? [View Quote] > When you say "log to a file" I assume you mean write to it? FTP allows > you to move entire files between machines. It doesn't supply a file > read/write interface. > > If you want to log to a local file then move it to another machine > that would be possible. I know that MFC has an FTP class that should > allow you to do this. Though you should wait for Walter to give you > the details. > > If you are in a Windows environment you can also do this by logging to > a local file and then copying the file into a shared directory. This > allows a fairly fast logging mechanism and a simple file move. If your > server is Lynx then Samba is a product that allows disk sharing with > windows using the NFS protocols. > > If you really want to write to a file on a remote machine then I would > suggest one of the following: > > 1. Again, in a windows environment, a simple solution would be to > share the remote directory onto the logging machine. It would not be > too much of an overhead to log to a file on the remote disk. Keep in > mind that these write operations will be blocking operations and that > a write to a network drive will be much slower than a write to a local > file. The delay added to you logger will depend on how much you want > to write to the file. > > 2. Another solution would be to write a little logging server that > listens on some socket, receives connections and writes anything that > is sent to it to a local file. Then your logger would just have to > connect to the log server at startup and write log messages to it. > Less overhead than a network disk but still some overhead. > > 3. The most efficient central logging design involves a proxy log > server that runs on the local machine. This proxy logger would receive > log messages from from processes on the same machine. It would be > responsible for forwarding them to a remote, central logging server. > This design decouples the time critical logger application from the > non time critical logging of messages operation. Ideally some shared > memory message exchange should be devised between the logger and the > proxy log server for optimum speed. > > I feel that I have said too much. > > Edward Sumerfield. > [View Quote] edward sumerfieldDec 5, 1998, 1:24pm
If you want to, go for it.
A simple solution to the ftp problem would be to use a bat file with the appropriate ftp command in it. Then use the C system("command.bat") to run it. The standard windows ftp client will do this for you. [View Quote] > What about having the program download the log off the FPT server than > writing to it an when you complete a session it uploads the log to the > server? > [View Quote] joshDec 5, 1998, 3:10pm
k, I was also thinking of getting a cgi that wrote to a html file on the net, and
when the program was started it would send info tot he cgi which would than write the log... [View Quote] > If you want to, go for it. > > A simple solution to the ftp problem would be to use a bat file with the > appropriate ftp command in it. Then use the C system("command.bat") to run it. > > The standard windows ftp client will do this for you. > [View Quote] edward sumerfieldDec 5, 1998, 3:28pm
I don't quite understand the architecture you are proposing.
Bot -> web server -> cgi -> log file or html file. If you want to write a cgi as a remote logging server that would be fine. Your bot would have to be a socket client, connect to the web server, talk HTTP to it passing the text to be written encoded as some kind of form field or get parameter. Then the cgi would parse the HTTP input fields and write to the log file. Some things to watch out for. A CGI program is started for every interaction with the web server so it is possible to have two bots connecting to the server at the same time which would mean some kind of file locking error if you are lucky or just a corrupted log file. The CGI standard is still extensively on the net these days but there are a number of newer standards that might make your life easier. Microsoft's ASP files allow you to write script to manage the requests to a web server, its easy to write and saves you all the hassles of parsing the HTTP protocol messages. Java Servlets supply a nice standard way of plugging in functionality to a web server. However, there are a number of free C based CGI libraries floating around that would help a great deal. Its up to you. Good luck. [View Quote] > k, I was also thinking of getting a cgi that wrote to a html file on the net, and > when the program was started it would send info tot he cgi which would than write > the log... > [View Quote] walter knupeDec 11, 1998, 3:28pm
Regarding Windows Support...
HTTP or FTP connections inside of windows are best done using the MFC classes designed around wininet.dll. They provide C++ classes like CHttpSession or CFtpSessions. the details for using them are to much to provide here, but watch out for the TEAR example which "tears" a web page from the net, means retrieves a page using CHttpSession to talk to a web server. regarding the logging you would want to log of course locally, and "post" the results to the net at the end of the session. Using HTTP; you Bot would have to perform as if sending a FORM result to the server. i think way to much work just for a file transfer. (not including the neccessary CGI to manage the log). So FTP sounds preferable. But FTP, as far as I know, does not allow to extend a file on the server, which would mean your bot has to download the ENTIRE existing log, write to it, and upload it again. this WILL be time consuming if the log gets big. Walter ps: Edward, you keep amazing me every time when you give a 2 page essay to a one-sentence-question :) Edward Sumerfield schrieb in Nachricht <36696D55.D1741095 at poboxes.com>... edward sumerfieldDec 11, 1998, 5:00pm
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html> I think I'll take that as a compliment Walter. Thank you. <p>You see the thing is, I am a high paid computer consultant whose current assignment is printing a sorting some reports. While totally frustrating and mind numbing, it does leave me with a fare amount of time on my hands. <p>Here's wishing for an interesting job one of these days. <p>Edward Sumerfield. [View Quote] walter knupeDec 11, 1998, 7:45pm
It was ment to be a compliment. Your answers usually include the answers to
2 or 3 questions that would follow, are very interesting to read and give many side-thoughts. I like them alot :) Walter Edward Sumerfield schrieb in Nachricht <36716BCE.7347122C at poboxes.com>... I think I'll take that as a compliment Walter. Thank you. |