• MPL Coding - firing a bash script??

    From paulie420@21:2/150 to All on Sun Dec 1 08:23:36 2024
    I know I've done this before - but lemme state what I'm doing. I'm needing to run a bash script on an external server from a Mystic MPL. I setup SSH keys and I can run the script with a;

    ssh user@x.x.x.x "bash /some/bash/script.sh"

    But I don't want the USER to wait on that command to finish. (It imports URLs a user enters into my ArchiveBox archive, but takes some minutes to finish...)

    So if I was just gonna run the command on the BBS CLI, I think I could just do;

    ssh user@x.x.x.x "bash /some/bash/script.sh" &

    ... is there some way I can successfully do this from the MPL? ... the MPL runs that above command and the script keeps running, and finishes, but the user gets dumped out before its done?

    Or, I could call the script NOT in MPL, from a separate Mystic menu command just after the MPL completes - that might be easier?

    Thats IF Mystic will run the script and drop out with the addition of "&" on the end. Anyway, if you know the answer to my questions pls reply. :P



    |07p|15AULIE|1142|07o
    |08.........

    --- Mystic BBS v1.12 A49 2024/05/29 (Linux/64)
    * Origin: 2o fOr beeRS bbs>>>20ForBeers.com:1337 (21:2/150)
  • From Gamgee@21:2/138 to paulie420 on Sun Dec 1 12:11:14 2024
    paulie420 wrote to All <=-

    I know I've done this before - but lemme state what I'm doing. I'm
    needing to run a bash script on an external server from a Mystic MPL. I setup SSH keys and I can run the script with a;

    ssh user@x.x.x.x "bash /some/bash/script.sh"

    But I don't want the USER to wait on that command to finish. (It
    imports URLs a user enters into my ArchiveBox archive, but takes some minutes to finish...)

    So if I was just gonna run the command on the BBS CLI, I think I could just do;

    ssh user@x.x.x.x "bash /some/bash/script.sh" &

    ... is there some way I can successfully do this from the MPL? ... the
    MPL runs that above command and the script keeps running, and finishes, but the user gets dumped out before its done?

    I don't know diddly about Mystic or MPL, but is it just as simple as
    including the '&' in the call to bash, thusly:

    ssh user@x.x.x.x "bash /some/bash/script.sh &" ?

    Easy enough to try, anyway.



    ... A day without sunshine is like night.
    === MultiMail/Linux v0.52
    --- SBBSecho 3.23-Linux
    * Origin: Palantir * palantirbbs.ddns.net * Pensacola, FL * (21:2/138)
  • From deon@21:2/116 to paulie420 on Mon Dec 2 08:01:04 2024
    Re: MPL Coding - firing a bash script??
    By: paulie420 to All on Sun Dec 01 2024 08:23 am

    Howdy,

    ... is there some way I can successfully do this from the MPL? ... the MPL runs that above command and the script keeps running, and finishes, but the user gets dumped out before its done?

    You might get a better answer, but one option might be to get your MPL to create a semaphore - and then have a cron job run every minute looking for it, and when it sees it, does what it needs to do.

    I think there might even be a filewatcher daemon of sorts (never used one myself), that comes to life instantly it sees the semaphore - which might be better if waiting up to 60s is not what you want...


    ...δεσ∩
    --- SBBSecho 3.20-Linux
    * Origin: I'm playing with ANSI+videotex - wanna play too? (21:2/116)
  • From deon@21:2/116 to paulie420 on Mon Dec 2 08:05:25 2024
    Re: Re: MPL Coding - firing a bash script??
    By: Gamgee to paulie420 on Sun Dec 01 2024 12:11 pm

    Howdy,

    I don't know diddly about Mystic or MPL, but is it just as simple as including the '&' in the call to bash, thusly:

    ssh user@x.x.x.x "bash /some/bash/script.sh &" ?

    In case the MPL kills the script because it returns immediately and closes the file descriptor, you might need a "nohup" in there.

    I think it would be something like "bash nohup ... &".


    ...δεσ∩
    --- SBBSecho 3.20-Linux
    * Origin: I'm playing with ANSI+videotex - wanna play too? (21:2/116)
  • From paulie420@21:2/150 to deon on Sun Dec 1 14:11:50 2024
    You might get a better answer, but one option might be to get your MPL to create a semaphore - and then have a cron job run every minute looking
    for it, and when it sees it, does what it needs to do.

    I think there might even be a filewatcher daemon of sorts (never used one myself), that comes to life instantly it sees the semaphore - which
    might be better if waiting up to 60s is not what you want...

    Thats a nice idea; I quite like it. Prior to this I was just running a cronjob once a day to update links that I have archived - but I wanted the project to start importing URLs immediately. I got it all ironed out, I ended up using a Mystic DD command, ssh and nohup;

    ssh user@x.x.x.x "nohup bash /home/user/some/script.sh > /dev/null 2>&1 &"

    When I just tacked an "&" on the end of an ssh command, the ssh instance would remain on the BBS system just sitting there - doing it this way uses ssh to run the script on a remote server, then it runs and finished on that remote but ssh drops on the BBS side immediately.

    Viola - works for this instance pretty well.

    Had to make sure the remote scripts had all variables and pwd's set correctly, as some of the shortening stuff I was using didn't have the infoz it needed. Thanks for the ideas gamgee & deon!



    |07p|15AULIE|1142|07o
    |08.........

    --- Mystic BBS v1.12 A49 2024/05/29 (Linux/64)
    * Origin: 2o fOr beeRS bbs>>>20ForBeers.com:1337 (21:2/150)
  • From The Godfather@21:3/165 to paulie420 on Wed Dec 4 18:40:31 2024
    ssh user@x.x.x.x "bash /some/bash/script.sh"

    If you do decide to go the .mpl route, I simply use

    MenuCmd('DD','/my/bbs/directory/themes/default/scripts/myscript.sh');

    I can send you the function I use for "the hitman" however it adds a lot of unecessary fwrite lines that temporarily save to send the webhook notification to my discord channel for the "hit" notification.

    Not sure if that is what you're looking for but .. thought I'd throw it out there

    |15-|12t|04G
    |15www|08.|15theun|07dergrou|08nd|07.|08us|15:|0810023

    ... I know a good tagline when I steal one!

    --- Mystic BBS v1.12 A49 2023/04/30 (Linux/64)
    * Origin: www.theunderground.us Telnet 10023 SSH 7771 (21:3/165)