• Tutor: Random TextFile Upload [BASH]

    From xqtr@21:1/101 to All on Monday, May 22, 2017 18:46:31

    ___
    ,----. ,--.'|_
    / / \-. | | :,' __ ,-.
    ,--, ,--,| : :| : : ' : ,' ,'/ /|
    |'. \/ .`| | .\ ..;__,' / ' | ' |
    ' \/ / ;. ; |: | | | | | ,'
    \ \.' / ' . \ |:__,'| : ' : /
    \ ; ; \ `. | ' : |__ | | '
    / \ \ \ `--'""| | | '.'|; : |
    ./__; ; \ | | ; : ;| , ;
    | :/\ \ ; | | : | , / ---'
    `---' `--` `---'.| ---`-'
    `---` 05/2017

    [ Tutorial ]

    Mystic BBS - Upload Random File

    ===============================================================================
    Lets see how we can make a BASH script and upload random files to a message base.

    We need a directory that will contain our files, to choose from. It may be ANSI files or Text files. Also you must copy and paste the code below to a new file and save it with a name like "uploadbot.sh" or anything you like. Also make the file executable, by giving this command in a BASH Shell:

    chmod +x ./uploadbot.sh

    Inside this script/file, there are some variables, that you may wish to configure, to your preferences. Do so and save the file. If everything is fine, by executing the script, should upload a random file, from your directory to the specified message base.

    The script is configured for Raspberry Pi, but you can easily change the directories and make it work, with any system. Just be careful, to put the right directories. The files that the script will choose from and upload them, are in the BOTDIR variable. Make sure that this directory exists and have files in it, otherwise you will get errors.

    ---[ COPY ]--------------------------------------------------------------------

    #!/bin/bash

    mysticdir="/home/pi/mystic"
    mutil="$mysticdir/mutil"
    botdir="$mysticdir/bots"
    inifile="$mysticdir/uprel.ini"

    msgbase=22
    from="AnotherDroid BBS"
    subj="XQTR Release"

    file=$(ls $botdir/ | shuf -n1)


    echo "[General]" > $inifile
    echo "" >> $inifile
    echo " PostTextFiles = true" >> $inifile
    echo " logfile = mutil.log" >> $inifile
    echo " loglevel = 3" >> $inifile
    echo " logtype = 1" >> $inifile
    echo " maxlogfiles = 31" >> $inifile
    echo " maxlogsize = 1500" >> $inifile
    echo "" >> $inifile
    echo "[PostTextFiles]" >> $inifile
    echo " " >> $inifile
    echo " totalfiles = 1" >> $inifile
    echo "" >> $inifile
    echo " file1_name = $botdir/$file" >> $inifile
    echo " file1_baseidx = $msgbase" >> $inifile
    echo " file1_from = $from" >> $inifile
    echo " file1_to = All" >> $inifile
    echo " file1_subj = $subj" >> $inifile
    echo " file1_addr = 21:1/111" >> $inifile
    echo " file1_delfile = false" >> $inifile

    $mutil $inifile -NOSCREEN

    -------------------------------------------------------------------------------

    Every time you want to upload a random Text/ANSI file to the specific message base, you just execute this script. But we can configure this to be done, auto- matically by using CRON. I will not explain in detail about CRON. Just follow the steps to create a CRON job and execute the script automatically.

    In the terminal give:

    crontab -e

    This will start a text editor (probably Nano) and load a Cron file. Go to the bottom of this file with PGDN and you should see something like this:

    ---[ SAMPLE ]------------------------------------------------------------------ # For more information see the manual pages of crontab(5) and cron(8)
    #
    # m h dom mon dow command -------------------------------------------------------------------------------

    In the last line press ENTER and write the following:

    00 */3 * * * /home/pi/mystic/uploadbot.sh

    Make sure that the script we saved earlier is inside Mystic directory and it's name is uploadbot.sh. Otherwise in the command above give the correct path and filename for the script.

    With this command we are telling Cron, to execute the script every three hours at exactly 00 minutes. For example it will upload a file, at 3:00, 6:00, 9:00 etc. If you wanted to upload a file every 6 hours we should change the */3 to */6.

    It is important that after typing this line, to press ENTER. Save the file... In Nano, you press CTRL+O to save and CTRL+X to exit. After exiting you should get a message that tells us, that the new job applied succesful.

    ///// NOTICE ////////////////////////////////////////////////////////////////

    Up to now, Mutil doesn't upload succesful ANSI files, probably a bug maybe... Perhaps in the future will be fixed. But for now, its uploading text files succesful.

    \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

    -------------------------------------------------------------------------------
    _ _ _ ___ _ _
    /_\ _ _ ___| _| _ ___ _ _ | \ _ _ ___(_)__| 8888
    / _ \| ' \/ _ \ _| ' \/ -_) '_| |) | '_/ _ \ / _` | 8 888888 8 /_/ \_\_|_\___/\__|__\___|_ |___/|_ \___/_\__,_| 8888888888
    8888888888
    DoNt Be aNoTHeR DrOiD fOR tHe SySteM 88 8888 88
    8888888888
    .o HaM RaDiO .o ANSi ARt! .o MySTiC MoDS "88|88"
    .o NeWS .o WeATheR .o FiLEs ""8888""
    .o GaMeS .o TeXtFiLeS .o PrEPardNeSS 88
    .o TuTors .o bOOkS/PdFs .o SuRVaViLiSM 8 8 88888888888
    .o FsxNet .o SurvNet .o More... 888 8888][][][888
    8 888888##88888
    TeLNeT : andr01d.zapto.org:9999 [UTC 11:00 - 20:00] 8 8888.####.888
    SySoP : xqtr eMAiL: xqtr.xqtr@gmail.com 8 8888##88##888

    .----- --- -- -
    | Another Droid BBS
    : Telnet : andr01d.zapto.org:9999 [UTC 11:00 - 20:00]
    . Contact : xqtr.xqtr@gmail.com

    --- Mystic BBS v1.12 A33 (Windows/32)
    * Origin: Agency BBS | telnet://agency.bbs.geek.nz (21:1/101)