• Brother printer install script

    From Grimble@2:250/1 to All on Sun Apr 3 16:50:30 2022
    I found the various posts in "Upgrading" very interesting, especially
    with the "Expect" application. I started to build a script to install my Brother printers but ran up against a "downloadend" redirection problem.
    I copied the URL for the driver install tool, which works well enough
    when executed from the Brother support page, but doesn't work when
    executed from a wget or curl command inside a script. Played around with --max-redirect (wget) and -L -J -O options (curl) but no success.
    Suggestions please.
    --
    Grimble
    Machine 'Haydn' running Plasma 5.20.4 on 5.15.28-desktop-1.mga8 kernel.
    Mageia release 8 (Official) for x86_64

    --- MBSE BBS v1.0.8 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From William Unruh@2:250/1 to All on Sun Apr 3 17:06:23 2022
    On 2022-04-03, Grimble <grimble@nomail.afraid.org> wrote:
    I found the various posts in "Upgrading" very interesting, especially
    with the "Expect" application. I started to build a script to install my Brother printers but ran up against a "downloadend" redirection problem.
    I copied the URL for the driver install tool, which works well enough
    when executed from the Brother support page, but doesn't work when
    executed from a wget or curl command inside a script. Played around with --max-redirect (wget) and -L -J -O options (curl) but no success.
    Suggestions please.

    Why would you not include the actual command from the script so we could
    see whether or not you had some error it, or to see if we could fix the problem.?
    And does wget or curl put out any error messages? Or do you dump the
    error messages to /dev/null (bad idea if you do while you are
    debugging).


    --- MBSE BBS v1.0.8 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Sun Apr 3 19:11:55 2022
    On Sun, 3 Apr 2022 16:50:30 +0100, Grimble wrote:
    I found the various posts in "Upgrading" very interesting, especially
    with the "Expect" application. I started to build a script to install my Brother printers but ran up against a "downloadend" redirection problem.
    I copied the URL for the driver install tool, which works well enough
    when executed from the Brother support page, but doesn't work when
    executed from a wget or curl command inside a script. Played around with --max-redirect (wget) and -L -J -O options (curl) but no success.
    Suggestions please.


    Your description is vague as to exactly what is done where with what.

    My printer scripts pull down the brother install script, disable all package managers except urpmi, install rpms that brother needs, remove any brother rpms, then unpack, run the brother install script via expect and
    re-enable other package managers upon script exit.

    I got a log of rpms installed by using the "script" command. Example:
    script -c " linux-brprinter-installer HL-L2380DW" printer_install.log
    the very first time I did the install.

    printer_install.log has a copy of all output sent to terminal/screen.

    urpmi has a "feature" where if you try in install an already installed
    rpm it removes the rpm name from a urpm list and gives some message about
    not doing something about rpm update. Since it has been years since I saw
    the message I can not remember it or the file you need to add the rpm
    back into. I put a wrapper around urpmi to not install a rpm already
    installed to not have the "feature" helping me into the ditch at a latter date.

    David W. Hodgins gave me the file name needing repair but I lost/forgot it.


    As to my wget arguments here is a snippet from my pull_printer script

    _app=pull_printer

    _app_dir=/var/local/data/$_app
    _index_fn=$_app.index
    _wget_args="--timeout=10 --quiet --no-remove-listing --output-document=$_index_fn"
    _wget_fn="$_app_dir/${_app}.wget.files"

    _hll2380dw_url='https://support.brother.com/g/b/downloadlist.aspx?c=us&lang=en&prod=hll2380dw_us_as&os=127'

    wget $_wget_args" $_hll2380dw_url $_wget_fn

    #*********************** end snippet*****************************

    To get url I navigated to my printer page and copied url into my script

    Note to expect users. If you run "autoexpect commands/args"
    it generates an expect script for you with the the exact output.

    If the verbiage ever changes the script will hang or fail. What I do
    is cut out the general verbiage and modify the script to ignore verbiage.

    Script answers n for test print and y to everything else.

    see attached expect script
    ----8<----8<----8<----8--cut below this line--8<----8<<
    #!/usr/bin/expect -f
    #
    # This Expect script was generated by autoexpect on Thu Jun 11 03:38:57 2020
    # Expect and autoexpect were both written by Don Libes, NIST.
    #
    # Note that autoexpect does not guarantee a working script. It
    # necessarily has to guess about certain things. Two reasons a script
    # might fail are:
    #
    # 1) timing - A surprising number of programs (rn, ksh, zsh, telnet,
    # etc.) and devices discard or ignore keystrokes that arrive "too
    # quickly" after prompts. If you find your new script hanging up at
    # one spot, try adding a short sleep just before the previous send.
    # Setting "force_conservative" to 1 (see below) makes Expect do this
    # automatically - pausing briefly before sending each character. This
    # pacifies every program I know of. The -c flag makes the script do
    # this in the first place. The -C flag allows you to define a
    # character to toggle this mode off and on.

    set force_conservative 1 ;# set to 1 to force conservative mode even if
    ;# script wasn't run conservatively originally
    if {$force_conservative} {
    set send_slow {1 .1}
    proc send {ignore arg} {
    sleep .1
    exp_send -s -- $arg
    }
    }

    #
    # 2) differing output - Some programs produce different output each time
    # they run. The "date" command is an obvious example. Another is
    # ftp, if it produces throughput statistics at the end of a file
    # transfer. If this causes a problem, delete these patterns or replace
    # them with wildcards. An alternative is to use the -p flag (for
    # "prompt") which makes Expect only look for the last line of output
    # (i.e., the prompt). The -P flag allows you to define a character to
    # toggle this mode off and on.
    #
    # Read the man page for more info.
    #
    # -Don


    set timeout 35
    spawn bash linux-brprinter-installer HL-L2380DW
    match_max 100000

    expect {

    -re "Test Print" {
    send -- "n\r"
    exp_continue
    }

    -re "destination Device URI." {
    send -- "I\r"
    exp_continue
    }

    -re "enter IP address" {
    send -- "192.168.11.190\r"
    exp_continue
    }

    -re "y/N" {
    send -- "y\r"
    exp_continue
    }

    -re "Y/n" {
    send -- "y\r"
    exp_continue
    }

    -re "OK?" {
    send -- "y\r"
    exp_continue
    }

    }
    expect eof
    #*********************** end of expect script above this line ********

    --- MBSE BBS v1.0.8 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Grimble@2:250/1 to All on Mon Apr 4 16:23:41 2022
    On 03/04/2022 17:06, William Unruh wrote:
    On 2022-04-03, Grimble <grimble@nomail.afraid.org> wrote:
    I found the various posts in "Upgrading" very interesting, especially
    with the "Expect" application. I started to build a script to install my
    Brother printers but ran up against a "downloadend" redirection problem.
    I copied the URL for the driver install tool, which works well enough
    when executed from the Brother support page, but doesn't work when
    executed from a wget or curl command inside a script. Played around with
    --max-redirect (wget) and -L -J -O options (curl) but no success.
    Suggestions please.

    Why would you not include the actual command from the script so we could
    see whether or not you had some error it, or to see if we could fix the problem.?
    And does wget or curl put out any error messages? Or do you dump the
    error messages to /dev/null (bad idea if you do while you are
    debugging).

    If I right click on Driver Support Tool in the Brother Support Downloads
    page and copy link address, I get https://support.brother.com/g/b/branch/downloadend.aspx?c=gb&lang=en&prod=hll2360dn_eu_as&os=127&dlid=dlf006893_000&flang=4&type3=625

    When executed from the script I was developing, it creates a text file
    called "downloadend", which cannot be executed to install any drivers. Googling around, I thought some redirection was involved. within the HTML.
    It is significantly different from the URL that Bit uses in his post.

    --
    Grimble
    Machine 'Haydn' running Plasma 5.20.4 on 5.15.28-desktop-1.mga8 kernel.
    Mageia release 8 (Official) for x86_64

    --- MBSE BBS v1.0.8 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Grimble@2:250/1 to All on Mon Apr 4 16:33:10 2022
    On 03/04/2022 19:11, Bit Twister wrote:
    On Sun, 3 Apr 2022 16:50:30 +0100, Grimble wrote:
    I found the various posts in "Upgrading" very interesting, especially
    with the "Expect" application. I started to build a script to install my
    Brother printers but ran up against a "downloadend" redirection problem.
    I copied the URL for the driver install tool, which works well enough
    when executed from the Brother support page, but doesn't work when
    executed from a wget or curl command inside a script. Played around with
    --max-redirect (wget) and -L -J -O options (curl) but no success.
    Suggestions please.


    Your description is vague as to exactly what is done where with what.

    My printer scripts pull down the brother install script, disable all package managers except urpmi, install rpms that brother needs, remove any brother rpms, then unpack, run the brother install script via expect and
    re-enable other package managers upon script exit.

    I got a log of rpms installed by using the "script" command. Example:
    script -c " linux-brprinter-installer HL-L2380DW" printer_install.log the very first time I did the install.

    printer_install.log has a copy of all output sent to terminal/screen.

    <snip>
    Summary reply: As usual your replies are informative - didn't know about
    the script command.
    The URL you used is very different from the one I found (see reply to William). I'll use it as a basis for my script.
    Thanks for the expect snippet; I'll build it in.


    --
    Grimble
    Machine 'Haydn' running Plasma 5.20.4 on 5.15.28-desktop-1.mga8 kernel.
    Mageia release 8 (Official) for x86_64

    --- MBSE BBS v1.0.8 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Mon Apr 4 17:37:40 2022
    On Mon, 4 Apr 2022 16:33:10 +0100, Grimble wrote:
    On 03/04/2022 19:11, Bit Twister wrote:
    On Sun, 3 Apr 2022 16:50:30 +0100, Grimble wrote:
    I found the various posts in "Upgrading" very interesting, especially
    with the "Expect" application. I started to build a script to install my >>> Brother printers but ran up against a "downloadend" redirection problem. >>> I copied the URL for the driver install tool, which works well enough
    when executed from the Brother support page, but doesn't work when
    executed from a wget or curl command inside a script. Played around with >>> --max-redirect (wget) and -L -J -O options (curl) but no success.
    Suggestions please.


    Your description is vague as to exactly what is done where with what.

    My printer scripts pull down the brother install script, disable all package >> managers except urpmi, install rpms that brother needs, remove any brother rpms, then unpack, run the brother install script via expect and
    re-enable other package managers upon script exit.

    I got a log of rpms installed by using the "script" command. Example:
    script -c " linux-brprinter-installer HL-L2380DW" printer_install.log >> the very first time I did the install.

    printer_install.log has a copy of all output sent to terminal/screen.

    <snip>
    Summary reply: As usual your replies are informative - didn't know about
    the script command.
    The URL you used is very different from the one I found (see reply to William). I'll use it as a basis for my script.

    Yup, I think I placed my mouse over the install script selection and right clicked
    to save url used in my scrit. Using firefox as browser.That link gets me a zipped file.

    Thanks for the expect snippet; I'll build it in.

    I would guess all you need to change is model number and printer IP to
    whatever you would normally enter.


    To keep form having to modify the install_printer and or expect script I
    create a link where needed. For example my install script does a:

    ln -sf linux-brprinter-installer* linux-brprinter-installer

    because Brother had/has the new version number on the executable name. :(


    FYI: list of package managers I to have disable/enable on my system.
    _pkg_mgrs="/usr/bin/dpkg /usr/bin/dnf /usr/bin/yum"

    Otherwise the brother installer script will pick one that I do not use.

    --- MBSE BBS v1.0.8 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From William Unruh@2:250/1 to All on Mon Apr 4 17:39:31 2022
    On 2022-04-04, Grimble <grimble@nomail.afraid.org> wrote:
    On 03/04/2022 17:06, William Unruh wrote:
    On 2022-04-03, Grimble <grimble@nomail.afraid.org> wrote:
    I found the various posts in "Upgrading" very interesting, especially
    with the "Expect" application. I started to build a script to install my >>> Brother printers but ran up against a "downloadend" redirection problem. >>> I copied the URL for the driver install tool, which works well enough
    when executed from the Brother support page, but doesn't work when
    executed from a wget or curl command inside a script. Played around with >>> --max-redirect (wget) and -L -J -O options (curl) but no success.
    Suggestions please.

    Why would you not include the actual command from the script so we could
    see whether or not you had some error it, or to see if we could fix the
    problem.?
    And does wget or curl put out any error messages? Or do you dump the
    error messages to /dev/null (bad idea if you do while you are
    debugging).

    If I right click on Driver Support Tool in the Brother Support Downloads page and copy link address, I get https://support.brother.com/g/b/branch/downloadend.aspx?c=gb&lang=en&prod=hll2360dn_eu_as&os=127&dlid=dlf006893_000&flang=4&type3=625

    When executed from the script I was developing, it creates a text file
    Well yes, it is NOT a download site. It is page which asks you to click
    to agree to the license and then it lets you download.


    No redirection. Just a click button to agree to the license.
    Try https://download.brother.com/welcome/dlf006893/linux-brprinter-installer-2.2.3-1.gz
    which is the where that button takes you.

    called "downloadend", which cannot be executed to install any drivers. Googling around, I thought some redirection was involved. within the HTML.
    It is significantly different from the URL that Bit uses in his post.


    --- MBSE BBS v1.0.8 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Mon Apr 4 17:46:17 2022
    On Mon, 4 Apr 2022 16:23:41 +0100, Grimble wrote:
    On 03/04/2022 17:06, William Unruh wrote:
    On 2022-04-03, Grimble <grimble@nomail.afraid.org> wrote:
    I found the various posts in "Upgrading" very interesting, especially
    with the "Expect" application. I started to build a script to install my >>> Brother printers but ran up against a "downloadend" redirection problem. >>> I copied the URL for the driver install tool, which works well enough
    when executed from the Brother support page, but doesn't work when
    executed from a wget or curl command inside a script. Played around with >>> --max-redirect (wget) and -L -J -O options (curl) but no success.
    Suggestions please.

    Why would you not include the actual command from the script so we could
    see whether or not you had some error it, or to see if we could fix the
    problem.?
    And does wget or curl put out any error messages? Or do you dump the
    error messages to /dev/null (bad idea if you do while you are
    debugging).

    If I right click on Driver Support Tool in the Brother Support Downloads
    page and copy link address, I get https://support.brother.com/g/b/branch/downloadend.aspx?c=gb&lang=en&prod=hll2360dn_eu_as&os=127&dlid=dlf006893_000&flang=4&type3=625

    When executed from the script I was developing, it creates a text file
    called "downloadend", which cannot be executed to install any drivers. Googling around, I thought some redirection was involved. within the HTML.
    It is significantly different from the URL that Bit uses in his post.

    Me thinks I used the rpm print driver link which would be s https://support.brother.com/g/b/downloadend.aspx?c=us&lang=en&prod=hll2360dw_us&os=127&dlid=dlf101914_000&flang=4&type3=558

    for a us rpm download for your printer.


    --- MBSE BBS v1.0.8 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)
  • From Bit Twister@2:250/1 to All on Mon Apr 4 18:13:46 2022
    On Mon, 4 Apr 2022 16:39:31 -0000 (UTC), William Unruh wrote:
    On 2022-04-04, Grimble <grimble@nomail.afraid.org> wrote:
    On 03/04/2022 17:06, William Unruh wrote:
    On 2022-04-03, Grimble <grimble@nomail.afraid.org> wrote:
    I found the various posts in "Upgrading" very interesting, especially
    with the "Expect" application. I started to build a script to install my >>>> Brother printers but ran up against a "downloadend" redirection problem. >>>> I copied the URL for the driver install tool, which works well enough
    when executed from the Brother support page, but doesn't work when
    executed from a wget or curl command inside a script. Played around with >>>> --max-redirect (wget) and -L -J -O options (curl) but no success.
    Suggestions please.

    Why would you not include the actual command from the script so we could >>> see whether or not you had some error it, or to see if we could fix the
    problem.?
    And does wget or curl put out any error messages? Or do you dump the
    error messages to /dev/null (bad idea if you do while you are
    debugging).

    If I right click on Driver Support Tool in the Brother Support Downloads
    page and copy link address, I get
    https://support.brother.com/g/b/branch/downloadend.aspx?c=gb&lang=en&prod=hll2360dn_eu_as&os=127&dlid=dlf006893_000&flang=4&type3=625

    When executed from the script I was developing, it creates a text file
    Well yes, it is NOT a download site. It is page which asks you to click
    to agree to the license and then it lets you download.


    No redirection. Just a click button to agree to the license.
    Try https://download.brother.com/welcome/dlf006893/linux-brprinter-installer-2.2.3-1.gz
    which is the where that button takes you.

    Yep, but now script is tied/hard coded to the version number. :-(

    Right clicking on the rpm install gets me https://support.brother.com/g/b/downloadend.aspx?c=us&lang=en&prod=hll2360dw_us&os=127&dlid=dlf101914_000&flang=4&type3=558

    agreement page. Glancing through my pull_printer script ,at the moment I
    can not see where the gz get on my machine. All I have is code to compare
    wget results to detect a new release is available. Starting to wonder
    if I go to brother site and download either my neighbor's or my printer
    by hand. If so I'll have to modify this script to either pull the .gz
    name from the download page or add the url for download.
    I'll find out next time there is a version up. Currently I have


    $_http_cmd $_url
    if [ $? -ne 0 ] ; then
    mail -s "$_app: wget rtn code $?" root < /dev/null
    fi
    #****************************************
    #* remove control chars and html brackets
    #****************************************

    tr -d ’\015’\033 < pull_printer.index > $_listing_fn
    tr '\[\]*<>"\r' ' ' < $_listing_fn > $_index_fn

    diff -bBw $_ref_fn $_index_fn > $_diff_fn
    if [ $? -ne 0 ] ; then
    mail -s "$_app: new updates for ${_who}'s printer" root < $_diff_fn
    cp --force $_index_fn $_ref_fn
    sleep 2
    fi


    --- MBSE BBS v1.0.8 (Linux-x86_64)
    * Origin: A noiseless patient Spider (2:250/1@fidonet)