• How to run cmd line task from within a BASIC program

    From Paul Stewart@21:1/5 to All on Sat Jan 1 21:10:39 2022
    Hi,

    I have a little WIMP program I have written in BASIC.
    As part of the Run file, it runs a *command and out puts results to a
    file. This works fine.

    However I would like to be able to run the same command within a procedure
    in the program to allow the file to be refreshed.

    I have tried using SYS "OS_CLI","ifconfig -a > <Wimp$ScrapDir>.ifinfo"
    This has the desired effect, being that it sends output of ifconfig -a to
    the ifinfo file in the scrap folder. However the program stops at this
    point :( Having opened a task window, and entered BASIC. Running the
    above SYS command exits BASIC and returns to command prompt. Obviously
    the same is occurring when attempting to run as part of the program and explains why it just stops without any error.

    Is SYS "OS_CLI" the correct command I should be using for this? Or is
    there another equally simple command to use that allows the program to
    continue after it has run?

    --
    Paul Stewart
    Sent from A9home running RISC OS 4.42

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harriet Bazley@21:1/5 to Paul Stewart on Sun Jan 2 01:06:42 2022
    On 1 Jan 2022 as I do recall,
    Paul Stewart wrote:

    I have a little WIMP program I have written in BASIC.
    As part of the Run file, it runs a *command and out puts results to a
    file. This works fine.

    However I would like to be able to run the same command within a procedure
    in the program to allow the file to be refreshed.

    I have tried using SYS "OS_CLI","ifconfig -a > <Wimp$ScrapDir>.ifinfo"
    This has the desired effect, being that it sends output of ifconfig -a to
    the ifinfo file in the scrap folder. However the program stops at this
    point :( Having opened a task window, and entered BASIC. Running the
    above SYS command exits BASIC and returns to command prompt. Obviously
    the same is occurring when attempting to run as part of the program and explains why it just stops without any error.

    Is SYS "OS_CLI" the correct command I should be using for this? Or is
    there another equally simple command to use that allows the program to continue after it has run?

    I think you probably need to do "SYS Wimp_StartTask" rather than trying
    to use OSCLI.

    See https://www.riscosopen.org/forum/forums/11/topics/1753 , for
    example.

    --
    Harriet Bazley == Loyaulte me lie ==

    Own nothing you do not know to be useful or believe to be beautiful.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Stewart@21:1/5 to Harriet Bazley on Sun Jan 2 20:29:31 2022
    In message <53513ba459.harriet@bazleyfamily.co.uk>
    Harriet Bazley <harriet@bazleyfamily.co.uk> wrote:

    I think you probably need to do "SYS Wimp_StartTask" rather than trying
    to use OSCLI.

    See https://www.riscosopen.org/forum/forums/11/topics/1753 , for
    example.

    Thanks Harriet. Exactly what I was looking for :)

    --
    Paul Stewart
    Sent from A9home running RISC OS 4.42

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Matthew Phillips@21:1/5 to All on Wed Jan 5 07:58:54 2022
    In message <53513ba459.harriet@bazleyfamily.co.uk>
    on 2 Jan 2022 Harriet Bazley wrote:

    On 1 Jan 2022 as I do recall,
    Paul Stewart wrote:

    I have a little WIMP program I have written in BASIC.
    As part of the Run file, it runs a *command and out puts results to a
    file. This works fine.

    However I would like to be able to run the same command within a procedure in the program to allow the file to be refreshed.

    I have tried using SYS "OS_CLI","ifconfig -a > <Wimp$ScrapDir>.ifinfo"
    This has the desired effect, being that it sends output of ifconfig -a to the ifinfo file in the scrap folder. However the program stops at this point :( Having opened a task window, and entered BASIC. Running the above SYS command exits BASIC and returns to command prompt. Obviously
    the same is occurring when attempting to run as part of the program and explains why it just stops without any error.

    Is SYS "OS_CLI" the correct command I should be using for this? Or is there another equally simple command to use that allows the program to continue after it has run?

    I think you probably need to do "SYS Wimp_StartTask" rather than trying
    to use OSCLI.

    See https://www.riscosopen.org/forum/forums/11/topics/1753 , for
    example.

    This comes from IfConfig being a separate program rather than being part of
    an operating system module. You can find it in
    $.!Boot.Resources.!Internet.bin

    The way the Wimp works any task when it is running is essentially single-tasking and running another program via the command line interpreter replaces the current program in memory. That's why you have to ask the Wimp
    to do it via Wimp_StartTask.

    The WISC OS Wimp is all a big conjuring trick so that you can seemingly multi-task on an operating system which is little different from the BBC
    Micro really. The low-level stuff like the command line interpreter knows nothing about multi-tasking.

    --
    Matthew Phillips
    Durham

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From druck@21:1/5 to Matthew Phillips on Wed Jan 5 18:02:12 2022
    On 05/01/2022 07:58, Matthew Phillips wrote:
    The way the Wimp works any task when it is running is essentially single-tasking and running another program via the command line interpreter replaces the current program in memory. That's why you have to ask the Wimp to do it via Wimp_StartTask.

    The WISC OS Wimp is all a big conjuring trick so that you can seemingly multi-task on an operating system which is little different from the BBC Micro really. The low-level stuff like the command line interpreter knows nothing about multi-tasking.

    You can still do the old BBC Micro trick of copying your self to higher
    in memory, and using OSCLI to run the task in the vacated lower memory.
    But its easier these days to use Wimp_StartTask as MP says.

    ---druck

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Gerph@21:1/5 to Paul Stewart on Wed Jan 19 16:53:20 2022
    On Saturday, 1 January 2022 at 21:10:47 UTC, Paul Stewart wrote:
    Hi,

    I have a little WIMP program I have written in BASIC.
    As part of the Run file, it runs a *command and out puts results to a
    file. This works fine.

    However I would like to be able to run the same command within a procedure in the program to allow the file to be refreshed.

    I have tried using SYS "OS_CLI","ifconfig -a > <Wimp$ScrapDir>.ifinfo"

    Which won't work because, as you've seen, it replaces your application. There is no process control on RISC OS, so you suffer here.

    However, your specific problem is that you want to read (I assume) information about the interfaces on the system. This is relatively trivial to do. How relative is a subjective matter, but it only needs calls that are defined in BSD sockets interfaces
    used by most systems. Because of this they're 'easily' translatable to RISC OS Socket calls. Some years ago I created some examples to show how this could be done in BASIC.

    The very old examples can be found on my usenet sharing site (https://usenet.gerph.org/Internet/), but a year ago I placed slightly improved versions in the RISC OS examples repository at https://github.com/gerph/riscos-examples/tree/master/networking/
    sockets

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Stewart@21:1/5 to Gerph on Thu Jan 20 19:54:07 2022
    In message <2e3fd371-c4c3-4993-9c94-3ef2d5ec15bbn@googlegroups.com>
    Gerph <gerph@gerph.org> wrote:

    On Saturday, 1 January 2022 at 21:10:47 UTC, Paul Stewart wrote:
    Hi,

    I have a little WIMP program I have written in BASIC.
    As part of the Run file, it runs a *command and out puts results to a
    file. This works fine.

    However I would like to be able to run the same command within a procedure >> in the program to allow the file to be refreshed.

    I have tried using SYS "OS_CLI","ifconfig -a > <Wimp$ScrapDir>.ifinfo"

    Which won't work because, as you've seen, it replaces your application.
    There is no process control on RISC OS, so you suffer here.

    However, your specific problem is that you want to read (I assume) information about the interfaces on the system. This is relatively trivial
    to do. How relative is a subjective matter, but it only needs calls that
    are defined in BSD sockets interfaces used by most systems. Because of
    this they're 'easily' translatable to RISC OS Socket calls. Some years ago
    I created some examples to show how this could be done in BASIC.

    The very old examples can be found on my usenet sharing site (https://usenet.gerph.org/Internet/), but a year ago I placed slightly improved versions in the RISC OS examples repository at https://github.com/gerph/riscos-examples/tree/master/networking/sockets

    Managed to do what I was looking at doing using SYS Wimp_StartTask, which Harriet pointed me too.

    I will however take look at your examples.

    --
    Paul Stewart
    Sent from A9home running RISC OS 4.42

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