D - http:// or ftp:// access
- Andrew Edwards (4/4) Jul 08 2003 Is it possible to download a file from the internet through a D program?
- Andrew Edwards (24/24) Jul 08 2003 This program is intended to remove the current installation of a program
- Burton Radons (15/17) Jul 08 2003 I put up a library for doing this back in March. Here's a copy of the
- Andrew Edwards (16/21) Jul 08 2003 Thanks! I've ran into a little trouble building the program though. It k...
- Burton Radons (6/21) Jul 10 2003 Sorry about the delay. There were problems with changed behaviour with
- Andrew Edwards (15/20) Jul 12 2003 I'm gracious for the update! Got some issues with it though! Prior to
- Burton Radons (3/22) Jul 12 2003 Please delete the files you copied over; they're not used anymore. I
- Andrew Edwards (11/13) Jul 12 2003 Done! I can compile the program but only from the \urllib directory or b...
- Andrew Edwards (25/25) Jul 09 2003 OK...
- J C Calvarese (5/17) Jul 09 2003 It looks like you need to add the lib to your command line, like so...
- Andrew Edwards (3/3) Jul 09 2003 Thanks! I picked up on that while I was at work today! Unfortunately I c...
- Andrew Edwards (5/7) Jul 09 2003 Great stuff Burton! I've completed the project and it works great! Thank...
Is it possible to download a file from the internet through a D program? Where might I find instructions on how to do such a thing? Thanks, Andrew
Jul 08 2003
This program is intended to remove the current installation of a program from my computer and install a new copy. PLMSZIP.exe extracts three files. OPEN.exe extracts multiple other files. The problem I'm running into is that the files get extracted at the location of NEWPLMSs.exe instead of into the pubs directory. Additionally I'd like to be able to get the PLMSZIP.exe file directly from the internet where it is updated quarterly. //: C02:newplms.d extern(C) int system(char*); int main() { // Remove current pubs directory system("rd c:\\pubs /s /q"); // create new directory system("md c:\\pubs"); // get plmszip.exe from internet // it is always at the same location // move program to directory system("move c:\\plmszip.exe c:\\pubs"); // Run program: This will extract 3 files system("c:\\pubs\\plmszip.exe"); // Extract remainder of files. system("c:\\pubs\\open.exe"); return 0; }
Jul 08 2003
Andrew Edwards wrote:Is it possible to download a file from the internet through a D program? Where might I find instructions on how to do such a thing?I put up a library for doing this back in March. Here's a copy of the release notes: I've put up a simple URL loading library at (http://www.opend.org/urllib.zip). It requires dig to be installed, although it doesn't use it, just digc. Comes with the documentation. It has the functions: urlopen: Open a URL as a stream (http, file, ftp, nntp, and dict schema supported). urlread: Open a URL and read its contents. urllistdir: List a directory, return an array of URLStat (file and ftp schema supported). urlencode, urldecode: Encode and decode the URL. The above functions expect a decoded URL. There's also a small, simple, not-thought-out sockets library.
Jul 08 2003
"Burton Radons" <loth users.sourceforge.net> wrote...I put up a library for doing this back in March. Here's a copy of the release notes: I've put up a simple URL loading library at (http://www.opend.org/urllib.zip). It requires dig to be installed, although it doesn't use it, just digc.Thanks! I've ran into a little trouble building the program though. It keeps squaking at me about undefined identifier 'Stream' in urllib_http.d(3). If I import stream into this file, it complaines about undefined identifier 'Socket' in the same file: urllib_http.d(23): identifier 'Socket' is not defined When I import socket.d into this file I get the following error: urllib.d(43): import string conflicts with stream.string at c:\dmd\bin\..\src\phobos\stream.d(1497) Obviously I'm doing something wrong. Please advise. ============= DMC installed: c:\dm DMD installed: c:\dmd dig installed: c:\dig (make install) // works fine urllib : c:\urllib (make) // errorlevel 1 PATH = d:\dm\bin;d:\dmd\bin;d:\dig;...
Jul 08 2003
Andrew Edwards wrote:"Burton Radons" <loth users.sourceforge.net> wrote...Sorry about the delay. There were problems with changed behaviour with private imports that needed amending, and the library didn't exploit digc's new library building method. The zip file's been updated to fix both, and I also added gopher (I'd been meaning to add it for awhile, but I couldn't find any active Gophers at the time!).I put up a library for doing this back in March. Here's a copy of the release notes: I've put up a simple URL loading library at (http://www.opend.org/urllib.zip). It requires dig to be installed, although it doesn't use it, just digc.Thanks! I've ran into a little trouble building the program though. It keeps squaking at me about undefined identifier 'Stream' in urllib_http.d(3). If I import stream into this file, it complaines about undefined identifier 'Socket' in the same file:
Jul 10 2003
"Burton Radons" <loth users.sourceforge.net> wrote in...Sorry about the delay. There were problems with changed behaviour with private imports that needed amending, and the library didn't exploit digc's new library building method. The zip file's been updated to fix both, and I also added gopher (I'd been meaning to add it for awhile, but I couldn't find any active Gophers at the time!).I'm gracious for the update! Got some issues with it though! Prior to installing the new and improved version, I was able to compile and run my program by moving socket.d and urllib.d to the phobos directory (initially placed in the dmd\src directory) and changing the private imports to public (deleted private keyword) in urllib.d. Your new installation no longer puts urllib.d or socket.d in the dmd\src directory. After copying the files (urllib_http.d copied to urllib.d) from the \urllib directory into dmd\src\phobos and recompiling my program, I get the following error: C:\d>dmd newplms urllib.lib newplms.d(11): undefined identifier urlread I have not changed the program except for adding a copyright and permission statement since I completed on Wednesday. Thanks for your help, Andrew
Jul 12 2003
Andrew Edwards wrote:"Burton Radons" <loth users.sourceforge.net> wrote in...Please delete the files you copied over; they're not used anymore. I meant to put that in the installation script and forgot about it.Sorry about the delay. There were problems with changed behaviour with private imports that needed amending, and the library didn't exploit digc's new library building method. The zip file's been updated to fix both, and I also added gopher (I'd been meaning to add it for awhile, but I couldn't find any active Gophers at the time!).I'm gracious for the update! Got some issues with it though! Prior to installing the new and improved version, I was able to compile and run my program by moving socket.d and urllib.d to the phobos directory (initially placed in the dmd\src directory) and changing the private imports to public (deleted private keyword) in urllib.d. Your new installation no longer puts urllib.d or socket.d in the dmd\src directory. After copying the files (urllib_http.d copied to urllib.d) from the \urllib directory into dmd\src\phobos and recompiling my program, I get the following error:
Jul 12 2003
"Burton Radons" <loth users.sourceforge.net> wrote...Please delete the files you copied over; they're not used anymore. I meant to put that in the installation script and forgot about it.Done! I can compile the program but only from the \urllib directory or by providing the location of all includes, which ended up looking like this: C:\d>dmd newplms c:\urllib\urllib.d c:\urllib\urllib_file.d c:\urllib\urllib_ftp .d c:\urllib\socket.d c:\urllib\urllib_http.d c:\urllib\urllib_dict.d c:\urllib\ urllib_nntp.d c:\urllib\urllib_gopher.d I can get the job done, so the update is not really that important. Thanks allot! Andrew
Jul 12 2003
OK... I've got it working somewhat! Here's an error I don't understand how to fix. ---------- Source Code ---------- //: C02:newdmd.d import stream; import urllib; // moved to phobos directory // used public vice private imports //extern(C) int system(char*); int main() { File newdmd = new File; byte[] dmd = urlread("ftp://ftp.digitalmars.com/dmd.zip"); newdmd.create("dmd.zip"); newdmd.writeExact(dmd,dmd.length); return 0; } ---------- Capture Output ---------- C:\dmd\bin\..\..\dm\bin\link.exe newdmd,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved newdmd.obj(newdmd) Error 42: Symbol Undefined _Durllib_urlread_FAaZAg --- errorlevel 1 Terminated with exit code 1
Jul 09 2003
---------- Capture Output ---------- C:\dmd\bin\..\..\dm\bin\link.exe newdmd,,,user32+kernel32/noi; OPTLINK (R) for Win32 Release 7.50B1 Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved newdmd.obj(newdmd) Error 42: Symbol Undefined _Durllib_urlread_FAaZAg --- errorlevel 1 Terminated with exit code 1It looks like you need to add the lib to your command line, like so... dmd new.d urllib.lib I got your program to compile and run (after massaging urllib AND phobos sources), so I think you're close. Justin
Jul 09 2003
Thanks! I picked up on that while I was at work today! Unfortunately I can't use or read newsgroups at work so I had to wait till I got back here! Andrew
Jul 09 2003
"Burton Radons" <loth users.sourceforge.net> wrote:I put up a library for doing this back in March. Here's a copy of the release notes:Great stuff Burton! I've completed the project and it works great! Thanks. Now if I could only get away from all those system() calls, I'd be in bussiness. Andrew
Jul 09 2003