View Single Post
  #4   (View Single Post)  
Old 30th January 2023
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,131
Default

No I did not use cat. Your use of cat is very clever, but I just did not think of it because I was refining my script that used read.

I am writing a little script to automate entries for the forum News section. I use the shell read to prompt for the title, url and quote.

I did not immediately realize that some news quotes were multiple lines. so I replaced the single read with a shell function that uses multiple reads. In other words I stayed within the limits of my self-imposed programming paradigm

Code:
#!/bin/sh

pastetext() {
    echo Paste text. To end paste, just type a '!' as only text at begin of line .....

    while read LINE ; do
      if [ "x$LINE" = "x!" ] ; then break ; fi
      if [ "x$TEXT" = "x" ]; then
           TEXT="$LINE"
      else     
           TEXT="$TEXT\n$LINE"
      fi
    done
}

cat <<END
Make News for daemonforums.org
------------------------------------------------------------------------
END



printf "\nURL of article/source : " 
read URL

printf "\nTitle : " 
read TITLE

printf "\nQuotation or description  : "
pastetext

echo ================= TEXT to paste =============
echo $TITLE
printf "From [url]$URL[/url]:[quote]$TEXT[/quote]\n"
echo ================= END OF TEXT ===============

# end of script
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote