Wget - working in browser but cannot download from wget

Hi,

I need to download a zip file from my the below US govt link.

https://www.sam.gov/SAMPortal/extractfiledownload?role=WW&version=SAM&filename=SAM\_PUBLIC\_MONTHLY_20160207.ZIP

I only have wget utility installed on the server.

When I use the below command, I am getting error 403 forbidden, but in browser, I am able to download.

$ wget https://www.sam.gov/SAMPortal/extractfiledownload?role=WW&version=SAM&filename=SAM_PUBLIC_MONTHLY_20160207.ZIP
[1]     42598834
[2]     46531048
xxxx : /home/xxxx $ --05:04:02--  https://www.sam.gov/SAMPortal/extractfiledownload?role=WW
           => `extractfiledownload?role=WW'
Resolving www.sam.gov... 66.77.18.172
Connecting to www.sam.gov[66.77.18.172]:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
05:04:03 ERROR 403: Forbidden.

How can I download the file from wget?

P.S:
I can able to download another zip file from same portal:

$ wget https://www.sam.gov/public-extracts/SAM-Public/SAM_Exclusions_Public_Extract_16061.ZIP
--05:07:06--  https://www.sam.gov/public-extracts/SAM-Public/SAM_Exclusions_Public_Extract_16061.ZIP
           => `SAM_Exclusions_Public_Extract_16061.ZIP'
Resolving www.sam.gov... 66.77.18.172
Connecting to www.sam.gov[66.77.18.172]:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5,303,014 [application/zip]

100%[=================================================================================================================>] 5,303,014     --.--K/s

05:07:11 (51.05 MB/s) - `SAM_Exclusions_Public_Extract_16061.ZIP' saved [5303014/5303014]

I beleive the '&' sign is creating a problem. Please suggest how to fix it

Try to escape the & char with a \ char.

---------- Post updated at 12:20 ---------- Previous update was at 12:16 ----------

With an unescaped & the shell will try to put the command line so far into background.

2 Likes

Thanks! Works perfectly!!