Me n My Perspectives

~ Wednesday, April 10 ~
Permalink

How to Use wget to download files in ubuntu?

wget is a network downloader,  so we can use it to download files from internet. Using wget, you can download webpages, download multiple files, download large files, you can also save offline copy of the webpages and many more. Here, I have covered simple usage and commands of wget which introduces you to wget.

  • You can download and save any particular webpage / file:

wget DESIRED/URL/PATH

This downloads the file pointed by the location ‘DESIRED/URL/PATH’.

If ‘DESIRED/URL/PATH’ is webpage, it downloads and saves the page

& if ‘DESIRED/URL/PATH’ is a file, it downloads the file and saves it.

  • You can give a new name to the file you are downloading:

wget -O newfilename.tar.gz DESIRED/URL/PATH/TO/FILE

When you are downloading the file, without renaming, it will take the default name (FILE) from the DESIRED/URL/PATH/TO/FILE, and you might not get the proper file name or extension of the downloaded file. So, you can rename the file to be downloaded with proper filename and extension.

  • You can specify bandwidth limit to the file being downloaded.

wget —limit-speed=100k newfilename.tar.gz DESIRED/URL/PATH/TO/FILE

This limits the speed of download or bandwidth for downloading the file to 100kb/s. (Helpful to download large file.)

  • You can also resume your old, interrupted / incomplete download with -c option.

wget -c —limit-speed=100k newfilename.tar.gz DESIRED/URL/PATH/TO/FILE

No worries if your download got interrupted and leave you with incomplete file. This will help you resume your old download. But make sure that you typed the same filename and are in the same path. (Helpful to download large file.)

  • You can also download multiple files using wget. All you need to do is write the list of path in a file and specify the file as follows.

wget -i my_download_list.txt

Make a file my_download_list.txt with the list of URLs separated into different lines. And it will download each of the files mentioned in the list. Make sure, each URLs are in a different line (Helpful to download multiple file.)

  • You can also download webpages and save for offline views.

wget —mirror —convert-links DESIRED/URL/PATH

This converts the dynamic contents of the website to static and saves a local copy for offline view.

  • Finally, you can run the downloads in background with -b option:

wget -b DESIRED/URL/PATH

This will run the downloads in background, and the progress is updated in a log file wget-log. So, you can monitor the progress with the following command.

tail -f wget-log

This will automatically update and show you the progress.

For further details, you can visit: http://manpages.ubuntu.com/manpages/precise/man1/wget.1.html or hit the command wget —help

Tags: ubuntu wget tutorial howto
1 note
Permalink

How to install Pip in both windows, ubuntu? Easiest way to start using virtual environment (virtualenv)

Following is the easiest way to install pip or start using virtual environment, straightaway without installing virtualenv.

It is a good idea to install pip to a virtual environment which is different from the system and doesn’t directly install python packages to the system python, so is a good choice if you work on multiple projects and are installing different python packages or different versions of python packages for different projects. You can refer to what-is-virtual-environment-why-is-it-needed for basic understanding about what is virtual environment and why is it needed, what is virtualenv, what is virtualenvwrapper.

To use pip, it is not mandatory that you need to install pip in the system directly. You can create a virtual environment and use it through virtualenv. What you can do is follow these steps:

  • download virtualenv tar.gz file from [https://pypi.python.org/pypi/virtualenv][1]
  • unzip it with 7zip or some other tools


We normally need to install python packages for one particular project. So, now create a project folder, lets say myproject.

  • COPY **virtualenv.py** file from decompressed folder of virtualenv, and PASTE inside **myproject** folder


Now Create Virtual Environment, lets say **myvirtualenv** as follows, inside **myproject** folder:

python virtualenv.py myvirtualenv

It will show you:

New python executable in myvirtualenv\Scripts\python.exe
Installing setuptools………………………………done.
Installing pip…………………….done.

Now your virtual environment **myvirtualenv** is created inside your project folder. You might notice, pip is now installed inside you virtual environment. All you need to do is activate the virtual environment with following command.
        (for windows)

myvirtualenv\Scripts\activate

        (for ubuntu)

source myvirtualenv/bin/activate

You will see following in the command prompt:

(myvirtualenv) PATH\TO\YOUR\PROJECT\FOLDER>pip install package_name


Now you can start using pip, but make sure you have activated the virtualenv looking at the left of your prompt.

This is one of the easiest way to install pip i.e. inside virtual environment, but you need to have virtualenv.py file with you.

You can also refer to more ways to install pip / virtualenv / virtualenvwrapper in other posts.

Tags: python pip virtualenv virtual environment Windows ubuntu