I’m more of a casual/newbie Linux user and I want to know if a specific Brother model is compatible with it. For reference, it’s the HL-L2465DW monochrome laser printer.

  • ejs@piefed.social
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 days ago

    I certainly wasn’t trying to “encourage” anything. I agree, blindly trusting commands is dangerous.

    In this context I present a specific explanation of how the install works. This adds to the novice’s knowledge, and allows them to begin to understand what my one-liner does.

    I think that without the context of instructions on how to do it manually, yes, you could make the case i’m enabling beginners to form/reinforce bad habits.

    • steel_for_humans@piefed.social
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 days ago

      As a Linux noob I like your oneliner but I agree with @solxix@pawb.social

      A more approachable way to do that would be to use wget and then manually run apt install with the downloaded file. That’s what I’ve been doing. :) Yours is “magic” ;)

      • ejs@piefed.social
        link
        fedilink
        English
        arrow-up
        1
        ·
        11 days ago

        Fair enough. Let me quickly go through the one-liner, command-by command

        # Joined by `&&`, bash runs these commands in sequence (as if run individually in shell), but exits/stops execution early if any command fails (return nonzero)
        TMP_DEB=$(mktemp --suffix=.deb) && curl -sSL "https://support.brother.com/g/b/downloadend.aspx?c=us&lang=en&prod=hll2465dw_us&os=128&dlid=dlf106036_000&flang=4&type3=10283" -o "$TMP_DEB" && sudo apt install -y "$TMP_DEB" && rm -f "$TMP_DEB"  
        
        # Going command by command:
        
        # First, we create a local variable in the shell, named `TMP_DEB`
        # We assign the value to `$(...)`. This stores the string output (to stdout) of running the command `mktemp ...` to `TMP_DEB`
        # `mktemp` creates a temporary file and prints its name, which uses the name template `tmp.XXXXXXXXXX`
        # `--suffix=.deb` flag appends `.deb` to the name template
        TMP_DEB=$(mktemp --suffix=.deb)
        
        # At this point, we've created a temporary file, and saved the name to a variable in bash
        # Next, we download the file using curl. `-s` makes output silent, `-S` shows errors in output, and `-L` follows redirects
        # note the url doesn't end in `.deb`, implying that we will be redirected by the web server to the file path. without -`L` curl will download a page that stores the redirection response from the web server, not the .deb package
        # `-o "$TMP_FILE"` forces curl to store the downloaded file to the tmp file we created
        # note the quotes around the variable expansion. `$TMP_FILE` would also resolve the string stored in the variable, but we use quotes to avoid string globbing (google this)
        curl -sSL "https://support.brother.com/..."
        
        # Next, we install the package with apt
        # note: we use the string stored in the variable `TMP_DEB`, the filepath to the temp file we created, and downloaded the deb package
        # `-y` flag skips the confirmation question "install package [y/n]: `
        sudo apt install -y "$TMP_DEB"
        
        # Finally, to clean up we delete the tmp file
        rm -f "$TMP_DEB"