Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Better way to check for wget

37 views
Skip to first unread message

Kevin Wells

unread,
Jan 20, 2021, 4:03:00 PM1/20/21
to
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.

Vince M Hudd

unread,
Jan 22, 2021, 7:15:36 AM1/22/21
to
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

Theo

unread,
Jan 22, 2021, 8:49:30 AM1/22/21
to
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 ...

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

Sprow

unread,
Jan 22, 2021, 1:20:20 PM1/22/21
to
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.

Kevin Wells

unread,
Jan 25, 2021, 10:28:03 AM1/25/21
to
In message <xoo*5x...@news.chiark.greenend.org.uk>
Theo <theom...@chiark.greenend.org.uk> 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 ...

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.

Kevin Wells

unread,
Jan 25, 2021, 10:28:03 AM1/25/21
to
In message <TrydnZhlbaR8XJf9...@giganews.com>
Vince M Hudd <atdotc...@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.)
>


--
Useless Fact 03 You burn 3.5 calories each time you laugh.

John Williams (News)

unread,
Jan 25, 2021, 12:18:05 PM1/25/21
to
In article <356d64f458.Kevin@Kevsoft>,
Kevin Wells <k...@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

Jonathan Harston

unread,
Jan 31, 2021, 7:23:17 AM1/31/21
to
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

Ronald

unread,
Jan 31, 2021, 6:24:06 PM1/31/21
to
In message <58f473d9...@tiscali.co.uk>
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
0 new messages