Best way to launch an app on booting
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Posts: 147 from 2013/8/25
    Hi all,

    I want to launch PolyOrga each time I boot, so it can play the role of a PIM more effectively.

    I have tried copying the program icon to WBStartup, which expectedly doesn't work (not seeing its various supporting files).

    I have also tried adding a line to user-startup:

    Code:
    Execute sys:applications/polyorga/orga

    But this doesn't work either. A quick look in an old AmigaDOS book suggests this is just for launching scripts. Run doesn't look quite either.

    What's the right way to do this?

    Thanks
  • »08.10.16 - 17:57
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    boot_wb
    Posts: 874 from 2007/4/9
    From: Kingston upon ...
    Quote:

    Ginger1 wrote:
    Hi all,

    I want to launch PolyOrga each time I boot, so it can play the role of a PIM more effectively.

    I have tried copying the program icon to WBStartup, which expectedly doesn't work (not seeing its various supporting files).

    I have also tried adding a line to user-startup:

    Code:
    Execute sys:applications/polyorga/orga

    But this doesn't work either. A quick look in an old AmigaDOS book suggests this is just for launching scripts. Run doesn't look quite either.

    What's the right way to do this?

    Thanks


    User-startup is for setting paths and assigns, and best kept clean of launching programs.

    The 'correct' way would be to copy its program icon to wbstartup (if dragging/dropping from ambient, switch to list view, and 'show all files' to access the icon (.info) file).
    You then need to view the icon information for the new file (the one in wbstartup) - set it to a 'project' icon type, and set the "default tool" path to point to the executable.

    It's also safe to use assigns in the paths, since programs are always launched from wbstartup afer startup-sequence & user-startup have returned.

    And yes, execute is for launching scripts (regardless of whether the script/executable flags are set).

    If the application/tool starts from the shell then a script can be used. The script is then given an icon (set to project, the 'script' and 'executable' flags are set, and c:iconx as default tool), and both script and icon are placed in wbstartup.

    One notable exception is where an application requires the network to be active before starting. In this case it may be best to use a script that waits for the network before launching the application, such as:

    Waitforport NETSTACK
    Run >NIL: path:to/your/executable

    (Whilst launching network-dependent applications can also be done from s:user-network-startup (which is executed at boot when the network stack starts), this script can run before user-startup, so it is not necessarily safe to rely on assigns here.)

    Best regards.

    PS - personally I think an "Add to WBStartup" macro should be a default context menu action for applications to automate the simple case. Fairly useless day-to-day, but perhaps helpful for new users.

    [ Edited by boot_wb 12.10.2016 - 00:47 ]
    www.hullchimneyservices.co.uk

    UI: Powerbook 5,6 (1.67GHz, 128MB VRam): OS3.1, OSX 10.5.8
    HTPC: Mac Mini G4 (1,5GHz, 64MB VRam): OS3.1 (ZVNC)
    Audiophile: Efika 5200b (SB Audigy): OS3.1 (VNC + Virtual Monitor)

    Windows free since 2011!
  • »08.10.16 - 18:16
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    defender
    Posts: 248 from 2011/4/24
    (boot_wb said it all anyway I did this:)

    run this from a shell or from ambient execute (Befehl ausführen)

    copy System:Applications/PolyOrga/Orga.info System:WBStartup/

    Open the drawer System->WBStartup right click on "Orga" proberties (Informationen)

    1. change the icon Type to Project
    2. point the requester for default tool (standard Programm) to your Orga executeable (System:Applications/PolyOrga/Orga)
    3. press the "new" button and type: DONOTWAIT "enter"
    4. press "save"
    ------------------------------------------------------------------------------------------------------------------------------------
    user-network-startup entry:

    run <>NIL: sys:applications/polyorga/orga donotwait

    does work as well

    (user-startup does not because the workbench has to be launched before you run Orga)

    [ Editiert durch defender 09.10.2016 - 01:13 ]
    PowerMac 3.6 - Radeon 9000_64Mb - 1,5Gb Ram - SB Live - MorphOS 3.9
    CD32 TF330 SILP Wifi- PowerBook 1,67GHz 1GB/100GB - MorphOS 3 reg. 1455 IMac Isight
  • »08.10.16 - 21:02
    Profile Visit Website
  • Acolyte of the Butterfly
    Acolyte of the Butterfly
    Posts: 147 from 2013/8/25
    Brilliant. Fantastic help. Thank you both!
  • »09.10.16 - 05:53
    Profile
  • jPV
  • Yokemate of Keyboards
    Yokemate of Keyboards
    jPV
    Posts: 2096 from 2003/2/24
    From: po-RNO
    Quote:

    Ginger1 wrote:
    I have also tried adding a line to user-startup:

    Code:
    Execute sys:applications/polyorga/orga

    But this doesn't work either. A quick look in an old AmigaDOS book suggests this is just for launching scripts. Run doesn't look quite either.



    If you want to launch workbench programs from any kinds of scripts, use the WBRun command. It changes directory to the executable's location (and thus finds its data files) and runs the program like double clicked from an icon (it reads tooltypes from the icon etc).


    Quote:

    boot_wb wrote:

    One notable exception is where an application requires the network to be active before starting. In this case it may be best to use a script that waits for the network before launching the application, such as:

    Waitforport netstat
    Run >NIL: path:to/your/executable



    You probably meant "waitforport NETSTACK" (typo & case-sensitive)

    But I've noticed that at the time when NETSTACK port appears, network isn't properly set yet (IP addresses might not be assigned etc), so I've been using this instead:
    WaitForPort inetd.ipc LOOP=30

    inetd.ipc is the last port appearing when starting up the TCP/IP stack and network is pretty much up on all aspects at that point. Loop is there to ensure that it'll wait for the network even if there is some delay (likely with wireless networks).


    [ Edited by jPV 11.10.2016 - 17:29 ]
  • »11.10.16 - 12:27
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    boot_wb
    Posts: 874 from 2007/4/9
    From: Kingston upon ...
    Quote:

    jPV wrote:
    Quote:

    Ginger1 wrote:
    I have also tried adding a line to user-startup:

    Code:
    Execute sys:applications/polyorga/orga

    But this doesn't work either. A quick look in an old AmigaDOS book suggests this is just for launching scripts. Run doesn't look quite either.



    If you want to launch workbench programs from any kinds of scripts, use the WBRun command. It changes directory to the executable's location (and thus finds its data files) and runs the program like double clicked from an icon (it reads tooltypes from the icon etc).


    Quote:

    boot_wb wrote:

    One notable exception is where an application requires the network to be active before starting. In this case it may be best to use a script that waits for the network before launching the application, such as:

    Waitforport netstat
    Run >NIL: path:to/your/executable



    You probably meant "waitforport NETSTACK" (typo & case-sensitive)


    I did, (corrected above), thanks for the correction.

    Quote:

    But I've noticed that at the time when NETSTACK port appears, network isn't properly set yet (IP addresses might not be assigned etc), so I've been using this instead:
    WaitForPort inetd.ipc LOOP=30

    inetd.ipc is the last port appearing when starting up the TCP/IP stack and network is pretty much up on all aspects at that point. Loop is there to ensure that it'll wait for the network even if there is some delay (likely with wireless networks).



    Good advice, thanks.

    NB - Doesn't WaitForPort loop indefinitely (with a default 1 second interval) if LOOP is not specified?
    If so, then the command above makes the script self-terminating after 30 loops, rather than extending its life to wait as long as needed. I admire 'self-terminating' as a principle in looping scripts :), but is this what was intended?
    www.hullchimneyservices.co.uk

    UI: Powerbook 5,6 (1.67GHz, 128MB VRam): OS3.1, OSX 10.5.8
    HTPC: Mac Mini G4 (1,5GHz, 64MB VRam): OS3.1 (ZVNC)
    Audiophile: Efika 5200b (SB Audigy): OS3.1 (VNC + Virtual Monitor)

    Windows free since 2011!
  • »11.10.16 - 21:46
    Profile Visit Website
  • jPV
  • Yokemate of Keyboards
    Yokemate of Keyboards
    jPV
    Posts: 2096 from 2003/2/24
    From: po-RNO
    Quote:

    boot_wb wrote:
    NB - Doesn't WaitForPort loop indefinitely (with a default 1 second interval) if LOOP is not specified?
    If so, then the command above makes the script self-terminating after 30 loops, rather than extending its life to wait as long as needed. I admire 'self-terminating' as a principle in looping scripts :), but is this what was intended?


    No, WaitForPort waits for 10 seconds by default which was way too small value for my wireless PB at least. With the loop=30 it waits for 30 seconds, which was enough in my cases, but could of course be set to bigger too if felt like that.
  • »12.10.16 - 05:13
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    boot_wb
    Posts: 874 from 2007/4/9
    From: Kingston upon ...
    That shd be interval 30 rather than loop 30 then. (Loop 1 is used as a single iteration test in network-startup to test for bsdsocket.library).

    [ Edited by boot_wb 12.10.2016 - 09:48 ]
    www.hullchimneyservices.co.uk

    UI: Powerbook 5,6 (1.67GHz, 128MB VRam): OS3.1, OSX 10.5.8
    HTPC: Mac Mini G4 (1,5GHz, 64MB VRam): OS3.1 (ZVNC)
    Audiophile: Efika 5200b (SB Audigy): OS3.1 (VNC + Virtual Monitor)

    Windows free since 2011!
  • »12.10.16 - 06:46
    Profile Visit Website
  • jPV
  • Yokemate of Keyboards
    Yokemate of Keyboards
    jPV
    Posts: 2096 from 2003/2/24
    From: po-RNO
    Quote:

    boot_wb wrote:
    That shd be interval 30 rather than loop 30 then. (Loop 1 is used as a single iteration test in network-startup to test for bsdsocket.library).


    Hmm? If you use interval 30, it waits the whole 30 seconds even if the port appears sooner. I don't think that's the wanted behaviour usually. At least I've meant that the command will exit if the network is up after 5 secs and it shouldn't still be waiting for extra 25 secs in that case. But it will wait up to 30 secs if the port doesn't seem to appear sooner.

    If you have loop 30 (and the default 1 secs interval) then it checks for the port each second and repeats that 30 times or until the port appears. If you have interval 30, then it only checks for the port after 30 secs if it wasn't initially found.

    The default values for WaitForPort are INTERVAL=1 and LOOP=10.

    Maybe I should have written "waits for max 30 seconds" in my previous post to be more exact :)

    [ Edited by jPV 12.10.2016 - 16:15 ]
  • »12.10.16 - 11:06
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    boot_wb
    Posts: 874 from 2007/4/9
    From: Kingston upon ...
    Quote:

    jPV wrote:
    Quote:

    boot_wb wrote:
    That shd be interval 30 rather than loop 30 then. (Loop 1 is used as a single iteration test in network-startup to test for bsdsocket.library).


    Hmm? If you use interval 30, it waits the whole 30 seconds even if the port appears sooner. I don't think that's the wanted behaviour usually. At least I've meant that the command will exit if the network is up after 5 secs and it shouldn't still be waiting for extra 25 secs in that case. But it will wait up to 30 secs if the port doesn't seem to appear sooner.

    If you have loop 30 (and the default 1 secs interval) then it checks for the port each second and repeats that 30 times or until the port appears. If you have interval 30, then it only checks for the port after 30 secs if it wasn't initially found.

    The default values for WaitForPort are INTERVAL=1 and LOOP=10.

    Maybe I should have written "waits for max 30 seconds" in my previous post to be more exact :)


    Aha! I'd misunderstood. :)
    www.hullchimneyservices.co.uk

    UI: Powerbook 5,6 (1.67GHz, 128MB VRam): OS3.1, OSX 10.5.8
    HTPC: Mac Mini G4 (1,5GHz, 64MB VRam): OS3.1 (ZVNC)
    Audiophile: Efika 5200b (SB Audigy): OS3.1 (VNC + Virtual Monitor)

    Windows free since 2011!
  • »13.10.16 - 08:36
    Profile Visit Website