Menu

Useful-Scripts Log in to Edit

Todd Andrews Mike MoxieMan
Attachments
active-lines (285 bytes)
blacklast (1543 bytes)
cidextract.py (1709 bytes)
csv2alias.tar (20480 bytes)
ncid-prog_gpio.sh (2205 bytes)
ncid-run_prog.sh (5630 bytes)

Here is a Wiki page to share useful scripts you may have developed.
Please attach them and add a description to this page.

  • active-lines <config file name> (contributed by Todd Andrews)

    will show uncommented, non-blank lines in a config file. I put it in /usr/local/bin.
    Example:

     $ active-lines /etc/ncid/ncidd.conf
     set ttyport = /dev/ttyACM1              # Linux USB modem 1
     set verbose = 7
     send cidlog
     send cidinfo
     set cidlogmax = 500000
     set lineid = HOMERPi
     $
    


  • blacklast (contributed by Mike)

    will add the most recent call to your blacklist. Handy when an annoying call comes in and you want to quickly and easily add it to the blacklist. The blacklist entry is also date stamped so the message from NCID will let you know when you blacklisted it. It's satisfying to see the message.

  • cidextract.py (contributed by MoxieMan)

    is another utility to help you manage your lists. I park it in /etc/ncid/. It parses the white and black lists, and looks in /var/log/cidcall.log (or a different file you specify from the command line), and prints out a list of phone numbers that have rung your number and aren't currently in a list. I run it using Python 2.7 on Fedora Core 24 currently. Only minor changes would be required for Python 3.x.

  • csv2alias.tar (contributed by Todd Andrews)

    contains script csv2alias.sh to convert a CSV file to STDOUT in the format needed for ncidd.alias. Handles CSV files with and without the first row containing column headings. Also handles first and last names in separate columns. Safely parses escaped/embedded commas. Includes some sample .csv files. Run csv2alias.sh without any parameters to see usage. Requires csvtk. Put csv2alias.sh and csvtk into /usr/local/bin. You need to be root to update ncidd.alias.
    Example to read customer-list.csv and append directly to ncidd.alias, then force ncidd server to refresh the alias list in memory:

     $ sudo bash
     # csv2alias.sh customer-list.csv Phone First Middle Last >> /etc/ncid/ncidd.alias
     # pkill -HUP ncidd
    


  • ncid-prog_gpio.sh, ncid-run_prog.sh (contributed by Alex)

    Use Raspberry Pi to suppress the first ring when a call is on the blacklist. Detailed instructions below.


Discussion

  • Mike

    Mike - 2016-06-28
     

    Last edit: Mike 2016-06-28
  • John L. Chmielewski

    It is a nice script but you should check that the line you got is actually a CID line and not one of the other supported types. Just in case.

     
    • Mike

      Mike - 2016-06-29

      It's a good point. I only use it for caller ID so that's the only records
      I ever see. It could make a bit of mess if it were not a CID line. Tail
      can't filter so I'll need to come up with something that searches backwards
      from the bottom of the file to find the last CID line.

      On Tue, Jun 28, 2016 at 5:20 PM, John L. Chmielewski jlc@users.sf.net
      wrote:

      It is a nice script but you should check that the line you got is actually
      a CID line and not one of the other supported types. Just in case.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/ncid/wiki/Useful-Scripts/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       
  • John L. Chmielewski

    No need to search backwards. Start at 10 or so from the end and if it is a CID line save it in a variable. Check the next line and if a CID replace the previous CID. And so on.

     
    • Mike

      Mike - 2016-07-01

      After a little thinking, it was pretty straightforward. First grep the callerid log so only lines starting with 'CID:' come out and pipe it to tail to grab only the last line. Unless your log is ridiculously big, it should be plenty fast.

       
  • MoxieMan

    MoxieMan - 2016-07-01

    As a small way of giving back, here is a script similar to the one above that I wrote and have been using to keep my white and black lists up to date. I park it in /etc/ncid/. It parses the white and black lists, and looks in /var/log/cidcall.log (or a different file you specify from the command line), and prints out a list of phone numbers that have rung your number and aren't currently in a list. I run it using Python 2.7 on Fedora Core 24 currently.

    Open to feedback to make it more robust.

     
    • Mike

      Mike - 2016-07-01

      Hi MoxieMan, Can you edit the Wiki? If yes, then go ahead and edit the page itself and attach your python script to main page. You're doing exactly what I hoped and adding your helpful tool.

       
      • MoxieMan

        MoxieMan - 2016-07-01

        Done.

         
  • Alex

    Alex - 2016-12-10

    Hello everyone,
    Here is a block-phone solution with a raspberry and NCID.
    So that only calls out blacklist make the phone ring:
    (The original discussion: https://sourceforge.net/p/ncid/discussion/275236/thread/04a533b0/?limit=25)

    - install 2016-09-23-raspbian-jessie-lite
    
    - update apt-get
    
    pi@raspberrypi:~ $ sudo apt-get update
    
    - Install gdebi
    
        pi@raspberrypi:~ $ sudo apt-get install gdebi
    
    - Download the prog or copy it with winscp in "/home/pi"
    
        pi@raspberrypi:~ $ wget http://sourceforge.net/projects/ncid/files/ncid/1.6/ncid_1.6-1_armhf.deb
    
        pi@raspberrypi:~ $ wget http://sourceforge.net/projects/ncid/files/ncid/1.6/ncid-client_1.6-1_all.deb
    
    - Install the server
    
        pi@raspberrypi:~ $ sudo gdebi ncid_1.6-1_armhf.deb
    
    - Install the client
    
        pi@raspberrypi:~ $ sudo gdebi ncid-client_1.6-1_all.deb
    
    - Configure the client
    
        pi@raspberrypi:~ $ sudo nano /etc/ncid/ncid.conf
    
            line 76: set Country "FR" (format display num tel)
            line 100: set AltDate 1 (format date dd/mm/yyyy)
    
    - Configure the server
    
        pi@raspberrypi:~ $ sudo nano /etc/ncid/ncidd.conf
    
            line 198: set cidnoname = 1 un-comment for displaying the number of the first ringtone
            line 223: set hangup = 1 un-comment for a simple hang up if the call number is in the blacklist
            se the file /etc/ncid/ncidd.conf From line 200 for all hangup options 
            line 376: set initstr = "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" un-comment to initialize the USR5637 modem
    
    - Restart the service to take changes 
    
        pi@raspberrypi:~ $ sudo invoke-rc.d ncidd restart
    
    - Start the prog in manual to test 
    
        pi@raspberrypi:~ $ ncidd
    
        pi@raspberrypi:~ $ ncid --no-gui
    
    - Put unwanted numbers in blacklist
    
        pi@raspberrypi:~ $ sudo nano /etc/ncid/ncidd.blacklist
    
        063********
        Or any other number as it appears in the file log "/var/log/cidcall.log"
        To prohibit all numbers starting with 06**
        ^06**
    
    - Restart the service to take changes
    
        pi@raspberrypi:~ $ sudo invoke-rc.d ncidd restart
    
    - Restart NCID automatically after reboot
    
        pi@raspberrypi:~ $ sudo update-rc.d ncidd defaults
    
    - To drive gpio or other prog if call 
    
        take exemple on /usr/share/ncid/modules/ncid-skel
        and its config file /etc/ncid/conf.d/ncid-skel.conf
    
    - Start a client who will call the prog
    
        pi@raspberrypi:~ $ ncid --no-gui --program ncid-le_prog
    
        example:
        Creates a program at this location
        pi@raspberrypi:~ $ sudo nano /usr/share/ncid/modules/ncid-prog_gpio.sh
        Copy in this code "ncid-prog_gpio.sh"
        Make it executable
        pi@raspberrypi:~ $ sudo chmod +x /usr/share/ncid/modules/ncid-prog_gpio.sh
        test
        pi@raspberrypi:~ $ sudo ncid --no-gui --program ncid-prog_gpio.sh
        Here sudo is required to enable gpio
    
    - Automate the startup of the client calling the prog ncid-prog_gpio.sh after a reboot
    
        Creates a file for the automatic startup script of the prog created before
    
        pi@raspberrypi:~ $ sudo nano /etc/init.d/ncid-run_prog.sh
        Copy in this code "ncid-run_prog.sh"
        Make it executable
        pi@raspberrypi:~ $ sudo chmod +x /etc/init.d/ncid-run_prog.sh
        Start it automatically
        pi@raspberrypi:~ $ sudo update-rc.d ncid-run_prog.sh defaults
    
    So this prog will launch in "sudo" the prog "ncid-prog_gpio.sh" after a reboot
    And the gpio 4 will be activated if the call number is not blacklist    
    

     

    Last edit: Alex 2016-12-12
    • Todd Andrews

      Todd Andrews - 2016-12-12

      Hi Alex, thanks for documenting this so thoroughly -- great job! The link to the hardware image appears to be broken, not sure if you're aware.

       
  • Alex

    Alex - 2016-12-12

    Ok thanks, the link is restored (this image is heberger on my site and i work on it ...)

     
  • Todd Andrews

    Todd Andrews - 2018-05-06

    Added active-lines attachment and added alphabetically to top post. Converted to bulleted list.

     
  • Todd Andrews

    Todd Andrews - 2019-08-15

    Added csv2alias.tar.

     
  • Todd Andrews

    Todd Andrews - 2019-08-15

    Put Alex's ncid-prog_gpio.shand ncid-run_prog.sh scripts in the main attachment list to make it easier to find.

    Added contributors to main descriptions.

     

Log in to post a comment.