• Better way to check for wget

    From Kevin Wells@21:1/5 to All on Wed Jan 20 20:58:08 2021
    Hi

    I use wget in a few of my applications and the check I use to see if
    wget is present is in the !Run file:

    If "<Wget$Dir>"= "" THEN Error error message.

    One of my users has wget in their Libary directory inside !Boot so my
    check fails to spot wget and they get that error.

    Is their a better way to check for wget, either in the !Run obey file or
    in the main application file in BASIC to check for wget?

    Thanks.

    --
    Kev Wells
    http://kevsoft.co.uk/ https://ko-fi.com/kevsoft
    carpe cervisium
    Useless Fact 02 In the artic the sun sometimes appears to be square.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vince M Hudd@21:1/5 to Kevin Wells on Fri Jan 22 12:15:28 2021
    On 20/01/2021 20:58, Kevin Wells wrote:

    [...]

    Is their a better way to check for wget, either in the !Run obey file or
    in the main application file in BASIC to check for wget?

    [As well as the current method of checking for a system variable]

    Off the top of my head, something along the lines of:

    IfThere "<Boot$Dir>.Library.wget" then Set <MyApp$WGet>
    If "<Wget$Dir>" <> "" THEN Set <MyApp$WGet>
    If "<MyApp$Wget>" = "" THEN Error message

    Not sure how sensible that is, TBH, having never needed to do something similar. (And not having a RISC OS machine switched on to check. e.g. is
    there a specific variable used for the library directory? Any other
    locations it could potentially be squirrelled away in? etc.)

    --
    Vince M Hudd - Soft Rock Software - www.softrock.co.uk
    RISCOSitory - www.riscository.com

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Theo@21:1/5 to Kevin Wells on Fri Jan 22 13:49:27 2021
    Kevin Wells <kev@kevsoft.co.uk> wrote:
    Is their a better way to check for wget, either in the !Run obey file or
    in the main application file in BASIC to check for wget?

    Perhaps something like:

    SYS "XWimp_StartTask", "wget -V" TO ;flags%
    IF (flags% AND 2) THEN ...

    I think you have to use Wimp_StartTask because if you use OS_CLI there's a
    risk of replacing your BASIC program with the wget application and being
    unable to return when it finishes.

    This is a check that wget is either somewhere on your Run$Path or an alias
    and can successfully execute - if you can run 'wget -V' you know you have a functioning program, whereas not being in an expected place is only one of
    the things that could go wrong.

    Theo

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Sprow@21:1/5 to Theo on Fri Jan 22 10:20:20 2021
    On Friday, January 22, 2021 at 1:49:30 PM UTC, Theo wrote:
    Kevin Wells <k...@kevsoft.co.uk> wrote:
    Is their a better way to check for wget, either in the !Run obey file or
    in the main application file in BASIC to check for wget?
    Perhaps something like:

    SYS "XWimp_StartTask", "wget -V" TO ;flags%
    IF (flags% AND 2) THEN ...

    There's a pecking order for how commands are searched for, if you were to use *wget then
    * Is it an alias?
    * Is it in a module?
    * Is it on Run$Path (which includes the library directory %)?

    If you only ever *Run wget that makes things easier because you don't need to worry about aliases or modules, and only Run$Path.
    Canonicalise (OS_FSControl 37) the name "wget" for "Run$Path,<Wget$Dir>." and see what you get back.
    Sprow.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kevin Wells@21:1/5 to Vince M Hudd on Mon Jan 25 14:23:05 2021
    In message <TrydnZhlbaR8XJf9nZ2dnUU7-XvNnZ2d@giganews.com>
    Vince M Hudd <atdotcodotuk@dotcodotukat.co.uk> wrote:

    On 20/01/2021 20:58, Kevin Wells wrote:

    [...]

    Is their a better way to check for wget, either in the !Run obey file or
    in the main application file in BASIC to check for wget?

    [As well as the current method of checking for a system variable]

    Off the top of my head, something along the lines of:

    IfThere "<Boot$Dir>.Library.wget" then Set <MyApp$WGet>
    If "<Wget$Dir>" <> "" THEN Set <MyApp$WGet>
    If "<MyApp$Wget>" = "" THEN Error message

    Thanks for this, but Ronald May sent me an idea off list, that got me an
    idea which I'm implementing in the application BASIC file rather than
    the !Run file, in which I use X wget and send the log into the
    applications scrap file and if the scrap file exist or not do what is
    required.

    Not sure how sensible that is, TBH, having never needed to do something >similar. (And not having a RISC OS machine switched on to check. e.g. is >there a specific variable used for the library directory? Any other
    locations it could potentially be squirrelled away in? etc.)



    --
    Kev Wells
    http://kevsoft.co.uk/ https://ko-fi.com/kevsoft
    carpe cervisium
    Useless Fact 03 You burn 3.5 calories each time you laugh.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kevin Wells@21:1/5 to Theo on Mon Jan 25 14:24:03 2021
    In message <xoo*5xRay@news.chiark.greenend.org.uk>
    Theo <theom+news@chiark.greenend.org.uk> wrote:

    Kevin Wells <kev@kevsoft.co.uk> wrote:
    Is their a better way to check for wget, either in the !Run obey file or
    in the main application file in BASIC to check for wget?

    Perhaps something like:

    SYS "XWimp_StartTask", "wget -V" TO ;flags%
    IF (flags% AND 2) THEN ...

    The trouble with that is it brings up the contents of wget -V in a
    window that has to be closed.

    Thanks for this, but Ronald May sent me an idea off list, that got me an
    idea which I'm implementing in the application BASIC file rather than
    the !Run file, in which I use X wget and send the log into the
    applications scrap file and if the scrap file exist or not do what is
    required.

    I think you have to use Wimp_StartTask because if you use OS_CLI there's a >risk of replacing your BASIC program with the wget application and being >unable to return when it finishes.

    This is a check that wget is either somewhere on your Run$Path or an alias >and can successfully execute - if you can run 'wget -V' you know you have a >functioning program, whereas not being in an expected place is only one of >the things that could go wrong.

    Theo


    --
    Kev Wells
    http://kevsoft.co.uk/ https://ko-fi.com/kevsoft
    carpe cervisium
    I am not an Alcoholic I am a Drunk. Alcoholics go to meetings.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John Williams (News)@21:1/5 to Kevin Wells on Mon Jan 25 17:12:31 2021
    In article <356d64f458.Kevin@Kevsoft>,
    Kevin Wells <kev@kevsoft.co.uk> wrote:

    I'm implementing in the application BASIC file rather than
    the !Run file, in which I use X wget and send the log into the
    applications scrap file

    You could always send it to null by redirection.

    John

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Jonathan Harston@21:1/5 to Vince M Hudd on Sun Jan 31 04:23:16 2021
    On Friday, 22 January 2021 at 12:15:36 UTC, Vince M Hudd wrote:
    Off the top of my head, something along the lines of:
    IfThere "<Boot$Dir>.Library.wget" then Set <MyApp$WGet>
    If "<Wget$Dir>" <> "" THEN Set <MyApp$WGet>
    If "<MyApp$Wget>" = "" THEN Error message

    UnSet Wget$Ok
    IfThere Run:wget Then Set Wget$Ok "Ok"
    If "<Wget$Dir>" <> "" Then Set Wget$Ok "Ok"
    If "<Wget$Ok>" = "" THEN Error message

    would check for the presence of a runnable wget, but not a local wget
    (eg in a module).

    The better method would be for your application to just simply issue
    a wget command and collect the error if it isn't found.

    SYS "XOS_CLI","Wimp_Task wget "+parameters$ TO r0%;f%
    IF (f% AND 1) THEN PROCreport("wget not available")

    Don't pre-assume. Attempt the action and deal with the response.

    "This is a BBC therefore there is no RealTimeClock" -> Wrong
    "There is no RTC, therefore there is no RTC" -> Correct

    jgh

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ronald@21:1/5 to UCEbin@tiscali.co.uk on Mon Feb 1 12:21:47 2021
    In message <58f473d9b3UCEbin@tiscali.co.uk>
    "John Williams (News)" <UCEbin@tiscali.co.uk> wrote:

    In article <356d64f458.Kevin@Kevsoft>,
    Kevin Wells <kev@kevsoft.co.uk> wrote:

    I'm implementing in the application BASIC file rather than
    the !Run file, in which I use X wget and send the log into the
    applications scrap file

    You could always send it to null by redirection.

    John

    Yes
    wget { > null: }
    would quit with 'File 'wget not found'
    It does run the binary to find out though.
    OTH it will find an alias also.

    Ifthere Run:wget Then Else Error wget not found
    only works for something in the Runpath, but also gives the
    option for alternative Error msg or alternative Else ...

    IfThere Run:wget Then Else If "<Wget$Dir>" = "" Then wget { > null: }

    only trys to run wget in the case of someone not using the
    standard issue wget app, but fits in the RunPath check first.
    Bordering on too many conditions for an Obey line, wasn't there
    an IfNThere available once?
    I think it is multiple Elses that lose their way.

    Possibly the 'which' utility would be best, includes modules.
    but we cant assume that it is installed.
    Maybe it should be mandatory.
    On a system with alias's possibly hidden away, the 'which' utility
    can reduce confusion.

    Only been looking at obey file options here
    Ronald May

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)