• My bash script

    From Alan Ianson@1:153/757 to All on Sat Aug 3 12:13:42 2019
    Hello All,

    I am using this in a bash script to toss incoming files here and am having a problem with it that I hope someone can shed some light on for me.

    ---- begin import mailin.sh ---

    # process tics
    if [ -f fido/inbound/*.tic ]; then
    ./bbbs btick > /dev/null 2>&1
    ./bbbs bfilsort > /dev/null 2>&1
    ./bbbs bfileidx > /dev/null 2>&1
    fi

    That is a snippit from my script that tosses inbound files. It works fine if there in just one inbound *.tic but if there are more than one tic to be processed it fails and I see this..

    scripts/mailin.sh: 14: [: fido/inbound/12345678.tic: unexpected operator

    I'm not sure what that means or how to overcome it. Any suggestions?

    One last question.. I have a second section like the aboveeeee that looks for *.TIC instead of *.tic. Is there a way to edit the above line to look for both *.tic and *.TIC?

    Thanks for any pointers.. :)

    --- BBBS/Li6 v4.10 Toy-4
    * Origin: The Rusty MailBox - Penticton, BC Canada (1:153/757)
  • From Deon George@3:633/509 to Alan Ianson on Sun Aug 4 12:23:50 2019
    Re: My bash script
    By: Alan Ianson to All on Sat Aug 03 2019 12:13 pm

    Hello All,
    I am using this in a bash script to toss incoming files here and am having a problem with it that I hope someone can shed some light on for me.

    if [ -f fido/inbound/*.tic ]; then

    there in just one inbound *.tic but if there are more than one tic to be processed it fails and I see this..

    Yeah, the reason it would fail, is the shell will expand it. IE: If you have 2 TIC's "a.tic", "b.tic", the command expands to:

    : if [ -f fido/inbound/a.tic fido/inbound/b.tic ]; then

    Which is a syntax error. There are probably many ways to do this, the way I would do it is:

    MOVED=0
    for i in fido/inbound/*.tic; do
    # If there are no files $i will equal "fido/inbound/*.tic"
    if [ "$i" == "fido/inbound/*.tic" ]; then continue; fi

    mv $i $destination;
    MOVED=1
    done

    if [ ${MOVED} -eq 1 ]; then
    ...
    fi

    One last question.. I have a second section like the aboveeeee that looks for *.TIC instead of *.tic. Is there a way to edit the above line to look for both *.tic and *.TIC?

    In my above example, you could have

    for i in fido/inbound/*.tic fido/inbound/*.TIC; do

    And then have another test for the uppercase *.TIC, that "continues".


    ...лоег
    --- SBBSecho 3.07-Linux
    * Origin: Alterant | An SBBS in Docker on Pi! (3:633/509)
  • From Alan Ianson@1:153/757 to Deon George on Sun Aug 4 08:09:50 2019
    Yeah, the reason it would fail, is the shell will expand it. IE: If you have 2
    TIC's "a.tic", "b.tic", the command expands to:

    : if [ -f fido/inbound/a.tic fido/inbound/b.tic ]; then

    Which is a syntax error. There are probably many ways to do this, the way I would do it is:

    OK, I'll need to change that.

    In my above example, you could have

    for i in fido/inbound/*.tic fido/inbound/*.TIC; do

    And then have another test for the uppercase *.TIC, that "continues".

    Thanks for the suggestions, I'll give that a try.. :)

    --- BBBS/Li6 v4.10 Toy-4
    * Origin: The Rusty MailBox - Penticton, BC Canada (1:153/757)