Search code examples
bashshelldownloadwget

Connection Error with wget in shell script


This is what my script looks like :

#!/bin/bash

WGETREF='https://ftp.1000genomes.ebi.ac.uk/vol1/ftp/technical/reference/GRCh38_reference_genome/GRCh38_full_analysis_set_plus_decoy_hla.fa'

wget $WGETREF
chmod +x get-ref.sh

I call it like so :

sbatch -A OD-projectID get-ref.sh

I tried doing a script because I will have to download lots of similar files that are 30+ Gb. When doing wget directly in the command line, it starts the download as it should. However with the shell script, the output file gives me the following error :

Connecting to ftp.1000genomes.ebi.ac.uk (ftp.1000genomes.ebi.ac.uk)|193.62.193.140|:443... failed: Connection refused.

Is there something I should add to my script ?

I tried different ways of writing the wget for instance calling for a 2nd script as so :

#!/bin/bash
wget -i url-ref.txt

with url-ref.txt being a simple text file with just the url.

Bash version : GNU bash, version 4.4.23(1)-release (x86_64-suse-linux-gnu).

This is what the debug output says :

DEBUG output created by Wget 1.20.3 on linux-gnu.

Reading HSTS entries from /home/foa003/.wget-hsts
URI encoding = ‘UTF-8’
asking libproxy about url 'https://ftp.1000genomes.ebi.ac.uk/vol1/ftp/technical/reference/GRCh38_reference_genome/GRCh38_full_analysis_set_plus_decoy_hla.fa'
libproxy suggest to use 'direct://'
Converted file name 'GRCh38_full_analysis_set_plus_decoy_hla.fa' (UTF-8) -> 'GRCh38_full_analysis_set_plus_decoy_hla.fa' (UTF-8)
--2023-05-18 11:36:52--  https://ftp.1000genomes.ebi.ac.uk/vol1/ftp/technical/reference/GRCh38_reference_genome/GRCh38_full_analysis_set_plus_decoy_hla.fa
Resolving ftp.1000genomes.ebi.ac.uk (ftp.1000genomes.ebi.ac.uk)... 193.62.193.140
Caching ftp.1000genomes.ebi.ac.uk => 193.62.193.140
Connecting to ftp.1000genomes.ebi.ac.uk (ftp.1000genomes.ebi.ac.uk)|193.62.193.140|:443... Closed fd 3
failed: Connection refused.
Releasing 0x00005555558eb020 (new refcount 1).

I tried adding ping google.com before wget and it seems to work


Solution

  • Adding ping google.com before wget helped