Thread: Download latest version problem

  1. #1
    Registered User
    Join Date
    Mar 2010
    Posts
    13

    Download latest version problem

    Please note I'm very new to c++

    I'm making a very simple program for a freshly formated PC.

    Basically once I run the program, it will download programs to a folder, like opera, vlc, etc.

    So in 5 seconds I have all the programs I commonly use downloading, so I don't have to spend time going to each site and downloading them individually.

    But I've run into a problem

    So far this is what I have

    Code:
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main()
    {
     int x;
    
    cout << "Type 1 to download \n Opera \n Firefox \n VLC \n Vuze \n Xfire \n Spybot \n ISO Recorder \n";
    cin >> x;
    
    
    if (x == 1)
    {
      system("start http://get3.opera.com/pub/opera/win/1051/en/Opera_1051_en_Setup.exe");
      system("start http://mirrors.yocum.org/mozilla/firefox/releases/3.6.3/win32/en-US/Firefox%20Setup%203.6.3.exe");
      system("start http://www.videolan.org/mirror-geo.php?file=vlc/1.0.5/win32/vlc-1.0.5-win32.exe");
      system("start http://hwcdn01.vuze.com/files/Vuze_Installer.exe");
      system("start http://www.spybotupdates.com/files/spybotsd162.exe");
      system("start http://isorecorder.alexfeinman.com/isorecorder.htm");
      system("start http://www.xfire.com/download/now/");
    }
    else
    {
    system("start www.google.com");
    }
    
    return 0;
    }
    The problem I have is, for example VLC, atm the current version of VLC is 1.0.5, and this downloads it "start http://www.videolan.org/mirror-geo.php?file=vlc/1.0.5/win32/vlc-1.0.5-win32.exe"

    But, in 6 months or when ever I reformat my PC, 1.0.5 won't be the latest version, so I don't know how to get it to always get the latest version.

    Any ideas?

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    You could update your code manually every six months with this one, it is only one screenful.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    13
    Quote Originally Posted by MK27 View Post
    You could update your code manually every six months with this one, it is only one screenful.
    I'm going to be adding a lot more programs, I first want to get the latests version part working- editing the code would defeat the purpose, if I was going to do that I might as well just go to each site and download individually.

  4. #4
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Well, I don't see a clear solution here that does not involve:

    1) an online source of information for each application involved, such as the homepage.
    2) an HTTP client to connect to that online source.
    3) a ton of nitty gritty parsing the content of the homepage to extract the current version. The you cross your fingers the homepage looks exactly the same in 6 months.

    In short, this could be a very interesting project, but considering you are brand new to C++, you might want to give yourself a month or so before you start considering the exact form of it, in order to get a firm grasp on syntax and some slightly more advanced topics such as networking (necessary) and OOP (very worthwhile).

    After that, you might be able to do this inside of a month, full time (30-60 hours a week) if you turn out to be a bit of a prodigy. But to be honest, I would bet against you getting anywhere close to accomplishing this before the end of the year. That's not a personal jibe at all.

    So, since it's basic syntax you need to master first, maybe put this one on the backburner for now.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  5. #5
    Registered User
    Join Date
    Mar 2010
    Posts
    13
    Ah, I didn't think it would be that difficult

    So your saying sites like this Ninite Easy PC Setup - Silent Unattended Install Multiple Programs At Once manually add the latest version of the programs each time a new version comes out?

  6. #6
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    Quote Originally Posted by paulb39 View Post
    I'm going to be adding a lot more programs, I first want to get the latests version part working- editing the code would defeat the purpose, if I was going to do that I might as well just go to each site and download individually.
    The path to the latest version of a program is determined, ultimately, by whoever develops that program.

    If you're lucky, the developer will publish the latest version number at some defined address (eg a file at http://wherever.the.program.is/latest_version.dat) that you can download, and then interpret to extract a path to the latest version. Most developers don't do that.

    In the end, you need to do it on a "case by case" for each program you're interested in. That might include crossing your fingers and doing some form of web page scraping (as mentioned by MK27). Such schemes are far from trivial, even if the web page for downloading a program of interest has a layout that never changes. Over time, if the developer changes layout of their web page, or changes their web address, or whatever .... then such schemes will fail. Some sites are also specifically designed to prevent automated downloads of their products (eg by showing an image for security purposes, that must be read by a human and typed in).

    For most programs, you're going to need some form of manual intervention. Whether that involves rewriting your program, or having some editable file that your program reads and you edit, is up to you.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  7. #7
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by paulb39 View Post
    Ah, I didn't think it would be that difficult
    that has been my response to most of the programming tasks I end up doing. It's like this: You think computers are like people, and that their existing capacities are innate, or at least already exist and are self managing. So you just have to say to them, "Okay, I know you can run this software, and install it, and go online and find some data and tell me the latest version" and so on.

    That is more like a user interface. Creating such an interface is somewhat more complicated.

    The "innateness" is more or less limited to what's called low level. Bytes, memory, input/output. Beyond that, you will be very surprised how complicated it is just to create a program that will fetch a webpage, like your browser does, because the computer does not do that "innately". It has to be programmed in terms of bytes, and memory, and input/output, to do that.

    So your saying sites like this Ninite Easy PC Setup - Silent Unattended Install Multiple Programs At Once manually add the latest version of the programs each time a new version comes out?
    Most likely they do, yes. This is a very minor task, all it requires is that someone do it periodically. I suppose history could have been such that all software applications could have a site and there could be some standared method of querying that site to get the latest version, but as it so happens this is not the case. That sort of relationship might be worked out between specific developers (eg, you as part of Ninite Easy PC Setup could work out a relationship with the development team of firefox such that you could automate version updates via simple online queries), or some of them might choose to offer it in some way already (if you inquire).

    Probably the reason support for this idea is "limited" is that the most useful side of programming involves tasks that are very repetitive and need to be done all the time, or perhaps extremely complex tasks that need to be done occasionally, as opposed to very simple tasks that only need to be done occasionally, and yet are still complex to develop and maintain (like this one)*. After all, why spend months working on something to save yourself 30 minutes a year from now on? The time you spend writing this application would be impossible to make up in a single lifetime. And chances are no one else will be that interested in it, because the time it would take someone else just to learn to use effectively (say several hours) is not worth the few minutes it will save them either.

    * there's a strange point about computers, that some things that are simple for a human user to do are more or less impossible for the computer to do on it's own, and other things that are very simple for a computer to do repetitively, at light speed, would be impossible or pointless for a human user to manually assist.
    Last edited by MK27; 04-26-2010 at 06:40 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Socket Programming Problem!!!!
    By bobthebullet990 in forum Networking/Device Communication
    Replies: 2
    Last Post: 02-21-2008, 07:36 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Picture download problem
    By wingri in forum C Programming
    Replies: 10
    Last Post: 07-31-2007, 05:32 AM
  4. Latest and greatest Problem
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 03-18-2002, 10:37 PM
  5. waste o' time: download the new DX version!!! [sarcasm...]
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-05-2001, 04:52 PM