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)