- The first solution (the one using source) did not work at all. The second worked somewhat but has its limitations. It is executing the script from the URL in a subshell.
- How to download files in Linux from command line with dynamic url. May 12, 2010 Introduction. Wget and curl, are great Linux operating system commands to download files.But you may face problems when all you have is a dynamic url.
I know how to use wget to download from ftp but I couldn't use wget to download from the following link:
How to Download a File From the Command Line In order to download files, you need to know at the very least the URL of the file you wish to download. For instance, imagine you wish to download the latest version of Ubuntu using the command line. Extract and copy the files to a directory such as C: Program Files wget and add that directory to you system’s path so you can access it with ease. Now you should be able to access wget from your Windows command line. The most basic operation a download manager needs to perform is to download a file from a URL.
If you copy and paste it in the browser, it'll start to download. But I want to download it to our server directly so I don't need to move it from my desktop to the server. How do I do it?
Thanks!
olalaolala1,46844 gold badges2323 silver badges3737 bronze badges
3 Answers
FedeCzFedeCz
Use the -O option with wget, to specify where to save the file that is downloaded. For example:
mti2935mti29358,12322 gold badges1717 silver badges2424 bronze badges
CristianCristian
Not the answer you're looking for? Browse other questions tagged urlunixdownloadwget or ask your own question.
I am trying to download a file from a website (ex. http://www.example.com/package.zip) using a Windows batch file. I am getting an error code when I write the function below:
The batch file doesn't seem to like the '/' after the http. Are there any ways to escape those characters so it doesn't assume they are function parameters?
Abel43.4k1717 gold badges117117 silver badges203203 bronze badges
JamesJames
18 Answers
With PowerShell 2.0 (Windows 7 preinstalled) you can use:
Starting with PowerShell 3.0 (Windows 8 preinstalled) you can use
Invoke-WebRequest
:From a batch file they are called:
(PowerShell 2.0 is available for installation on XP, 3.0 for Windows 7)
Abel43.4k1717 gold badges117117 silver badges203203 bronze badges
Bash Download File From Url To Pdf
sevenforcesevenforce5,08722 gold badges2121 silver badges2121 bronze badges
There's a standard Windows component which can achieve what you're trying to do: BITS. It has been included in Windows since XP and 2000 SP3.
Run:
The job name is simply the display name for the download job - set it to something that describes what you're doing.
brainwoodbrainwood
This might be a little off topic, but you can pretty easily download a file using Powershell. Powershell comes with modern versions of Windows so you don't have to install any extra stuff on the computer. I learned how to do it by reading this page:
The code was:
David GraysonDavid Grayson59.7k2020 gold badges113113 silver badges151151 bronze badges
Last I checked, there isn't a command line command to connect to a URL from the MS command line. Try wget for Windows:
http://gnuwin32.sourceforge.net/packages/wget.htm
http://gnuwin32.sourceforge.net/packages/wget.htm
or URL2File:
http://www.chami.com/free/url2file_wincon.html
http://www.chami.com/free/url2file_wincon.html
In Linux, you can use 'wget'.
Alternatively, you can try VBScript. They are like command line programs, but they are scripts interpreted by the wscript.exe scripts host. Here is an example of downloading a file using VBS:
https://serverfault.com/questions/29707/download-file-from-vbscript
https://serverfault.com/questions/29707/download-file-from-vbscript
![Bash Download File From Url Bash Download File From Url](/uploads/1/2/6/5/126589812/230206485.png)
4,21399 gold badges2222 silver badges3636 bronze badges
LostInTheCodeLostInTheCode1,61922 gold badges1313 silver badges2222 bronze badges
Kalpesh SoniKalpesh Soni3,68911 gold badge3232 silver badges4040 bronze badges
Downloading files in PURE BATCH...
Without any JScript, VBScript, Powershell, etc... Only pure Batch!
Some people are saying it's not possible of downloading files with a batch script without using any JScript or VBScript, etc... But they are definitely wrong!
Here is a simple method that seems to work pretty well for downloading files in your batch scripts. It should be working on almost any file's URL. It is even possible to use a proxy server if you need it.
For downloading files, we can use BITSADMIN.EXE from the Windows system. There is no need for downloading/installing anything or using any JScript or VBScript, etc. Bitsadmin.exe is present on most Windows versions, probably from XP to Windows 10.
Enjoy!
USAGE:
You can use the BITSADMIN command directly, like this:
bitsadmin /transfer mydownloadjob /download /priority normal 'http://example.com/File.zip' 'C:DownloadsFile.zip'
Proxy Server:
For connecting using a proxy, use this command before downloading.
For connecting using a proxy, use this command before downloading.
bitsadmin /setproxysettings mydownloadjob OVERRIDE 'proxy-server.com:8080' '<local>'
Click this LINK if you want more info about BITSadmin.exe
CUSTOM FUNCTIONS
:DOWNLOAD_FILE 'URL'
:DOWNLOAD_PROXY_ON 'SERVER:PORT'
:DOWNLOAD_PROXY_OFF
I made these 3 functions for simplifying the bitsadmin commands. It's easier to use and remember. It can be particularly useful if you are using it multiple times in your scripts.
PLEASE NOTE...
Before using these functions, you will first need to copy them from CUSTOM_FUNCTIONS.CMD to the end of your script. There is also a complete example: DOWNLOAD-EXAMPLE.CMD
Before using these functions, you will first need to copy them from CUSTOM_FUNCTIONS.CMD to the end of your script. There is also a complete example: DOWNLOAD-EXAMPLE.CMD
:DOWNLOAD_FILE 'URL'
The main function, will download files from URL.
The main function, will download files from URL.
:DOWNLOAD_PROXY_ON 'SERVER:PORT'
(Optional) You can use this function if you need to use a proxy server.
Calling the :DOWNLOAD_PROXY_OFF function will disable it.
(Optional) You can use this function if you need to use a proxy server.
Calling the :DOWNLOAD_PROXY_OFF function will disable it.
EXAMPLE:
CALL :DOWNLOAD_PROXY_ON 'proxy-server.com:8080'
CALL :DOWNLOAD_FILE 'http://example.com/File.zip' 'C:DownloadsFile.zip'
CALL :DOWNLOAD_PROXY_OFF
CUSTOM_FUNCTIONS.CMD
DOWNLOAD-EXAMPLE.CMD
Frank EinsteinFrank Einstein
AFAIK, Windows doesn't have a built-in commandline tool to download a file. But you can do it from a VBScript, and you can generate the VBScript file from batch using echo and output redirection:
More explanation here
AbscissaAbscissa
- Download Wget from here http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-setup.exe
- Then install it.
- Then make some .bat file and put this into it
- Adjust the URL and the file path in the script
- Run the file and profit!
boksioraboksiora
You cannot use xcopy over http. Try downloading wget for windows. That may do the trick. It is a command line utility for non-interactive download of files through http. You can get it at http://gnuwin32.sourceforge.net/packages/wget.htm
Matt WrockMatt Wrock
If bitsadmin isn't your cup of tea, you can use this PowerShell command:
TrinitrotolueneTrinitrotoluene
Use Bat To Exe Converter
Create a batch file and put something like the code below into it
Create a batch file and put something like the code below into it
or
and convert it to exe.
kentuckyschreitkentuckyschreit
BATCH may not be able to do this, but you can use JScript or VBScript if you don't want to use tools that are not installed by default with Windows.
The first example on this page downloads a binary file in VBScript:http://www.robvanderwoude.com/vbstech_internet_download.php
This SO answer downloads a file using JScript (IMO, the better language):Windows Script Host (jscript): how do i download a binary file?
Your batch script can then just call out to a JScript or VBScript that downloads the file.
Community♦
aikeruaikeru2,83833 gold badges2828 silver badges4040 bronze badges
This should work i did the following for a game server project. It will download the zip and extract it to what ever directory you specify.
Save as name.bat or name.cmd
Original : https://github.com/C0nw0nk/SteamCMD-AutoUpdate-Any-Gameserver/blob/master/steam.cmd
C0nw0nkC0nw0nk39211 gold badge33 silver badges1414 bronze badges
Instead of wget you can also use aria2 to download the file from a particular URL.
See the following link which will explain more about aria2:
Nisse Engström4,21399 gold badges2222 silver badges3636 bronze badges
Linux C++ Download File From Url
SasikumarSasikumar
I found this VB script:
Works like a charm. Configured as a function with a very simple function call:
Originally from: http://www.ericphelps.com/scripting/samples/BinaryDownload/index.htm
Here is the full code for redundancy:
BeachhouseBeachhouse3,66122 gold badges2121 silver badges3333 bronze badges
This question has very good answer in here. My code is purely based on that answer with some modifications.
Save below snippet as wget.bat and put it in your system path (e.g. Put it in a directory and add this directory to system path.)
You can use it in your cli as follows:
wget url/to/file [?custom_name]
where
url_to_file
is compulsory and custom_name
is optional- If name is not provided, then downloaded file will be saved by its own name from the url.
- If the name is supplied, then the file will be saved by the new name.
The file url and saved filenames are displayed in ansi colored text. If that is causing problem for you, then check this github project.
P.S. This code requires you to have PowerShell installed.
Community♦
bantyabantya
You can setup a scheduled task using wget, use the “Run” field in scheduled task as:
Nisse Engström4,21399 gold badges2222 silver badges3636 bronze badges
lv10lv1071666 gold badges1919 silver badges3939 bronze badges
use ftp:
Change everything in asterisks to fit your situation.
user212218
Kirill ShilovKirill Shilov
protected by Community♦Jun 17 '17 at 14:02
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Would you like to answer one of these unanswered questions instead?