![]() |
| ||
| How to pass the parameters to a script? Hi. I don't know anything about python but I need to use a script which I have found on the internet. I don't know where to start. I have installed python on my windows xp desktop and I have also downloaded and put in the Lib folder the file BeautifulSoup.py (http://www.crummy.com/software/BeautifulSoup/) since I know that the script needs it. The aim of the script is to generate an html file with a list of links based on the name of a linux package. Infact I need to use this script to download all the *.deb files of a given package plus all the .deb files which depend upon that a package from http://packages.ubuntu.com/. I guess that it's very easy to use this script but I don't know how! Help would be really appreciated.
If i try to run it I get: Traceback (most recent call last): |
| ||
| Re: How to pass the parameters to a script? Hi balance, How are you running it? The error occurs because the "downloader" module, urllib, has a urlopen() function which doesn't recognize the URL being passed in. If you step backwards, you see that the error is in line 15 of UbuntuPackageGrabber.py, the main script. That line says: source = urllib.urlopen(url).read()where 'url' is an input parameter to the get_debs() function. If we then look for where the get_debs() function is called, we see that it's at line 40 of the same program, which is: packages = get_debs(sys.argv[0])So 'url' is really sys.argv[0]. In case you didn't know, sys.argv is the list of command-line tokens, and sys.argv[0] ought to be the first of those tokens, the program name (all other tokens start at 1 and continue in that fashion). So the script tells urllib to open a URL with the same name as the script? This seems like it should be a bug! What is the input to this script supposed to be? A package name? Because it seems like it's expecting a URL. Is that URL supposed to be http://packages.ubuntu.com? Is it supposed to be the link for the package? I have no idea what's going on, and I can't find this script through Google. Do you have a link to the script's documentation? |
| ||
| Re: How to pass the parameters to a script? First of all thank you for your kind reply! Unfortunately I don't have the documentation of the script! You're right I should pass an url to the script. For example it should be possible to pass an url like this: http://packages.ubuntu.com/gutsy/base/adduser My problem is that I don't know how to pass it. Maybe sys.argv[0] is used to pass the url directly from the command line? But also if this was true, I wouldn't know how to do it! Hoping that you can tell me how to pass the url to the script Thanks in advance. |
| ||
| Re: How to pass the parameters to a script? Hi balance, You should open a command prompt, navigate to the directory where the script is, and invoke it by saying: python UbuntuPackageGrabber.py URL_GOES_HERESubstitute the package URL you have in mind. But I still think it will misfire, unless you change sys.argv[0] to sys.argv[1]. Try it both ways and see what happens. |
| All times are GMT -4. The time now is 7:07 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC