• Perl help

    From bamageek@21:1/140 to All on Monday, September 04, 2017 13:16:56
    I've never done Perl before, but I'm trying to throw a little script together that will check to see if mis2 is running and if not restart it. This is what
    I have so far. The only issue is I want the script to run and then terminate itself but when it starts mis2 looks like it opens up in the terminal window that the script is running. This may not be a bad thing as I was going to set up a cron job or something to check every hour, but I wanted the script to
    also check other things like mchat as well:

    #!/usr/bin/perl

    use strict;
    use warnings;
    my $mis2bsy = '/mystic/semaphore/mis2.bsy';
    my $mis2running = 0;
    if (-e $mis2bsy) {
    open(my $fh, '<:encoding(UTF-8)', $mis2bsy)
    or die "Unable to open mis2.bsy";
    my $mis2id = <$fh>;
    $mis2running = kill 0, $mis2id;
    }

    if ( $mis2running ) {
    print "mis2 is running!\n";
    } else {
    exec ('/mystic/mis2res.sh') or print STDERR "Could not launch mis2 restart s$
    }


    mis2res.sh:
    #!/bin/sh
    sudo rm /semaphore/mis2.bsy
    sudo /mystic/mis2 root /mystic server

    /**Dave's BBS telnet://davesbbs.com
    * @version 2.0 fsxNet: 21:1/140
    * GatorNet: 57:57/38
    **/

    --- Mystic BBS v1.12 A35 (Raspberry Pi/32)
    * Origin: fsxNet: Daves BBS (21:1/140)
  • From Malthous@21:1/189 to bamageek on Monday, September 04, 2017 19:49:11
    it. This is what I have so far. The only issue is I want the script to
    run and then terminate itself but when it starts mis2 looks like it
    opens up in the terminal window that the script is running. This may not

    You could call fork and fork off the process to start mis2. Then the script could continue processing.

    http://perldoc.perl.org/perlfork.html

    --Malthous--

    --- Mystic BBS v1.12 A35 (Linux/64)
    * Origin: KernelError Networks BBS (21:1/189)