Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9313473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:53:30+00:00 2026-06-19T01:53:30+00:00

I wrote I simple bash script to wget an archive from iblocklist.com and extract

  • 0

I wrote I simple bash script to wget an archive from iblocklist.com and extract it to my transmission blocklists dir. After it failed to run several times I found that the .gz archive being pushed by iblocklist was corrupt but the .zip was not so I decided to implement some error catching and an alternate means of accomplishing the task. After rewriting the script, I get unexpected EOF error and I cannot find where the problem lies. I’m by no means an advanced user of bash but I can usually accomplish what I want through trial and error and google. Not today. I’ve looked for the obvious missing }, fi, and ;’s but it looks good to me. Not sure if it matters but on this machine I’m running a Backtrack linux distro that more or less forces you to be root at all times. I’m a beginner so please be gentle 🙂

#!/bin/bash

function test {
    "$@"
        STATUS=$?
    if [ $STATUS -ne 0 ]; then
        echo "error with $1";
    fi

    return $STATUS
}

function askyn {
    read -p "The operation failed. Try alternate means? [Y/n] " -n 1 -r
    if [[ "$REPLY" =~ ^[Yy] ]] || [[ "$REPLY" = "" ]]; then YN=1;
    else YN=0; fi
    return $YN
}

function cleanup {
    if [ $ALT == 0 ]; then {
        test rm /root/scripts/.lvl1/dl/level1.gz
        if [ $STATUS -ne 0 ]; then {
            echo Removal of archive failed
        }fi
    }else {
        test rm /root/scripts/.lvl1/dl/level1.zip
        if [ $STATUS -ne 0 ]; then {
            echo Removal of archive failed
        }fi
    }fi
    return
}

ALT=0
YN=-1
test wget "http://list.iblocklist.com/?list=bt_level1&fileformat=p2p&archiveformat=gz" -O /root/scripts/.lvl1/dl/level1.gz
if [ $STATUS -ne 0 ]; then { #wget failed first try
    askyn
    if [ $YN == 1 ]; then ALT=1;else exit;fi #prompt for alternate; exit if not
}else { #wget worked first try
    test file-roller -e /root/.config/transmission/blocklists /root/scripts/.lvl1/dl/level1.gz
    if [ $STATUS -ne 0 ]; then { #file-roller failed to extract the list
        askyn
        if [ $YN == 1 ]; then ALT=1;else exit;fi #prompt for alternate; exit if not
    }else { #everything worked first try
        echo Download and extraction successful
        cleanup
    }fi
}fi
if [ $ALT == 1 ]; then { #try to wget .zip
    test wget "http://list.iblocklist.com/?list=bt_level1&fileformat=p2p&archiveformat=zip" -O /root/scripts/.lvl1/dl/level1.zip
    if [ $STATUS -ne 0 ]; then { #wget of .zip failed
        echo Alternate means failed.  Exiting.
        exit
    }else { #wget of .zip worked 
        test unzip -o -d /root/.config/transmission/blocklists /root/scripts/.lvl1/dl/level1.zip #try to unzip .zip
        if [ $STATUS -ne 0 ]; then { #unzip failed
            echo Alternate means failed.  Exiting.
            exit
        }else { #everything worked second try
            echo Download and extraction successful using alternate means
            cleanup
        }fi
    }fi
}fi
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T01:53:31+00:00Added an answer on June 19, 2026 at 1:53 am

    The problem is your use of }fi to terminate an if. The token }fi is not a fi. So the shell at the end of the file has a lot of open ifs missing their fis.

    You are in dire need of reading the shell manual, understanding shell grammar, and asking your local shell guru. The script as written is fubar, even with the syntax errors corrected.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a super simple bash script to get me into a python shell
I wrote a simple bash script because I was using a grep command with
This is a very simple bash script I wrote: #!/bin/bash ITEM_LIST=items.txt LOG_FILE=log.log TOTAL_ITEMS=$(wc -l
I have written a very simple bash script to help me migrate from dev
Hi I've a question about feeding inputs to this simple bash script I wrote.
I wrote a simple test program for opencv to see if it's working after
I wrote a simple PHP shell script which parses files and outputs certain element.
I am trying to write a simple bash script that will search for files
I'm trying to write a simple bash script that accepts all arguments and interprets
I am trying to write a very simple bash script in order to add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.