Skip to content
ggodart edited this page Jan 6, 2021 · 25 revisions

These programs are included in MisterHouse mh/bin directory. Most of these are meant to be called from MisterHouse events, as separate processes, but they can also be run stand alone. You can get the help text for most of these programs with the -h option (e.g. get_tv_grid -h).

Table of contents


alpha_page

Sends alphanumeric page.

Usage:

    alpha_page [options]

      -h              => This help text
      -help           => This help text
      -name xyz       => name of recipient (must be defined in mh.ini)
      -pin xyz        => pin number
      -message xyz    => text of message to send

Example:

alpha_page -pin 123456 -message 'Bring home bread and milk' alpha_page -name craig -message 'Bring home bread and milk'

backup_data

Walks directories and stores selected files to gziped tar files.

Usage:

   backup_data [options] dir1 dir2 etc

    -h        => This help text

    -file xyz => Name of tar file.  Default is backup
    -size xyz => Do NOT store files > xyz KBytes.  Default is 100
    -skip xyz => Skip any file or dir that matches regex xyz
    -age  xyz => Only back up files changed in the last xyz days

    -no_zip   => Do NOT gzip the tar file.
    -no_zip   => Do NOT suffix the files with date stamp.

    -int      => Use the internal perl tar and gzip modules, rather
                 then external tar and gzip programs.  This is slower
                 and users more memory (> the data being tared).

Examples:

backup_data /www backup_data -size 10 -no_zip -int /usr/local/bin backup_data -file /backup/misc /bin //misterhouse.net/bin backup_data -file /backup/mh -skip "(/tv$)|(/articles$)" /misterhouse backup_data -file /backup/mh_articles -size 100000 /misterhouse/articles backup_data -file /backup/docs -age 30 -size 100000 /docs

display

Use this to display a string of text or the contents of a file using a Tk window.

Usage:

    display -options  text_or_file

  Options:
    -time  xyz to have the window auto-close in xyz seconds.  Set to 0 for no auto-close.
    -font  xyz to pick the font
    -title xyz to set the window title

Examples:

display weather_forcast.txt display -title 'triva answer' c:/data/triva_answer.txt display "Remember to take out the garbage" -time 0

display_callers

Use this to display a Tk window with a list of the incoming and outgoing phone logs. An example of how to create these logs is in `mh/code/bruce/phone.pl

Usage:

    display_callers (no argument -> uses latest logs)
    display_callers 1997_11  (Look only at November, 1997 logs)

find_files Finds files on shared networked Windows and samba directories

Usage:

   find_files [options] search_string

    -h or -help  => This help text
    -v           => Verbose (shows dirs as they are searched)

    -boxes x,y,z => Search for files on boxes x,y, and z.  Defaults to all.
    -dirs  x,y,z => Search only dirs x,y, and z.  Defaults to all.
    -skip  x,y,z => Ignore files/dirs with strings x,y, and z.

Examples:

find_files mp3 find_files -v -boxes "house,dm,c2" mp3 find_files -dirs "//house/c,//dm/d" mp3

find_programs

Finds programs running on networked Windows computers.

Requires WMI to be installed on both/all computers.

Usage:

   find_programs [options] box_list [search_string]

    box_list is a comma delimited list of boxes to search
    search_string lists only programs that match

   options:
    -h or -help  => This help text
    -all         => Show/search all programs

Examples:

find_programs house find_programs "house,dm,c2" quake find_programs -all "house,dm,c2"

get_email

Use this program to check all the email accounts defined in your mh.ini file. It will create the following files:

  mh/data/get_email.data
     It uses this database so see what email is new
     since it was last called.   To get a complete
     list of all email (not just new/recent mail).
     delete this file before running get_email

  mh/data/get_mail.txt
     This summarizes how much mail there is and from who.
     Here is an example of what the file might look like:

       Email account bruce has 2 new email messages from John Doe and Bill Gates

  mh/data/get_mail.flag
     This has a string of digits, one for each account,
     that shows how much mail is each account.

  mh/data/email
     This directory will have one weeks worth of html mail files,
     by account and day (e.g. winter_tue.html), as well as a
     latest.html file that just shows the unreceived mail.

You can create a get_email_rule.pl file to control how this program summarizes mail. See get_email_rule_example.pl for an example.

Use the mh.ini net_mail_scan_age parm to set the age, in minutes, of email to report/scan. If blank, (default), get_email reports on all mail on your server. If your have your mail client set to 'leave mail on server' (useful if you want to use appliances like Audrey to also read mail), you will probably want to set this to something like 15.

Here is an example of how to call it from MisterHouse (see mh/code/common/internet_mail.pl for the complete example):

  $p_get_email = new Process_Item('get_email');
  start $p_get_email if !$Save{sleeping_parents} and
                        $New_Minute and !($Minute % 20) and &net_connect_check;

  if (done_now $p_get_email) {
      my $email_text = file_read "$Pgm_Root/data/get_email.txt";
      speak "rooms=all $email_text" if $email_text;
      $Save{email_flag} = file_read "$Pgm_Root/data/get_email.flag";
  }
  &tk_mlabel(\$Save{email_flag});

get_mp3_data

Reads mp3 directories and stores the results in a dbm file. This data is used by mh/bruce/mp3_playlist/pl to search/play mp3 tag data, file names, and playlist files.

Usage:

   get_mp3_data [options] dir1 dir2 etc

    -h        => This help text
    -help     => This help text

    -dbm  xyz => Stores the data in dbm file xyz.

Examples:

get_mp3_data c:\mp3 d:\mp3 get_mp3_data -dbm e:\mh\data\mp3_dbm c:\mp3

get_tv_grid

- WARNING this program is broken because because the source of the data went away, 
- please use get_tv_grid_xmltv, which can use the XML coming from SchedulesDirect and XMLTV.. 

Gets a TV grid/schedule from the web (clicktv.com) and changes so it to be used by the MisterHouse program to create VCR and TV event reminders. Creates a DBM for use by get_tv_info.

Usage:

   get_tv_grid [options]
    -h        => This help text
    -help     => This help text
    -userid xyz   => xyz is your clicktv userid.  Go to http://clicktv.com  to
                     create one, or to find the generic one that matches your
                     local tv schedule.
    -day xyz      => xyz is the day  to get/filter.  Default is today.
    -hour xyz     => xyz is the hour to get/filter.  Default is 6pm.  Can also
                     be 'all' to get all hours.
    -days xyz     => xyz is the number of days to get/filter, starting
                     with -day.
    -channels xyz => xyz is the number of channels to filter.  Default is 999.
    -infile  xyz  => xyz is  original input file.   Default is
                     web/tv/clicktv/day_hour.html.  If this file is missing
                     or old, a new file will be retrieved from the web.
    -outfile xyz  => xyz the filtered output file.
                     Default is -outdir/day_hour.html
    -outdir  xyz  => xyz the directory the outfiles will be put in.
                     Default is mh.ini parm html_dir/tv
    -label xyz    => Use xyz as the link lable.  Default is "VCR".
    -reget        => Re-read  the clicktv web page, even if a recent file it
                     already exists.
    -redo         => Re-write -outfile xyz, even if it already exists.
    -keep_old     => Do NOT delete data from the DBM that is one month older
                     than todays date
    -debug        => turn on debug info

    -mail_to      xyz => Will email the charts to xyz
    -mail_server  xyz => xyz is the SMTP host.  Default is localhost
    -mail_baseref xyz => xyz is the http address of your mh server.  Needed if
                         you want to control mh from the emailed web page

Example:

    get_tv_grid -day 25 -hour 4pm -outfile my_tv.html
    get_tv_grid -days 7 -hour all
    get_tv_grid -email bruce@misterhouse.net -mail_baseref misterhouse.net:8090

Usage:

    get_tv_grid [options]

  Options:
    -h        => This help text
    -help     => This help text

    -zip xyz      => xyz is your zip code
    -provider xyz => xyz is your TV provider ID.  See note below

    -day xyz      => xyz is the day  to get/filter.  Default is today.
    -hour xyz     => xyz is the hour to get/filter.  Default is 6pm.
                     Can also be 'all' to get all hours.

    -days xyz     => xyz is the number of days to get/filter, starting with -day.

    -channels xyz => xyz is the number of channels to filter.  Default is 999.

    -infile  xyz  => xyz is  original input file.   Default is web/tv/clicktv/day_hour.html
                     If this file is missing or old, a new file will be retreived from
                     the web.

    -outfile xyz  => xyz the filtered output file.
                     Default is -outdir/day_hour.html

    -outdir  xyz  => xyz the directory the outfiles will be put in.
                     Default is mh.ini parm html_dir/tv

    -label xyz    => Use xyz as the link lable.  Default is "Set the Vcr"

    -reget        => Re-read  the clicktv web page, even if a recent file it already exists.
    -redo         => Re-write -outfile xyz, even if it already exists.

    -debug        => turn on debug info

    -mail_to      xyz => Will email the charts to xyz
    -mail_server  xyz => xyz is the SMTP host.  Default is localhost
    -mail_baseref xyz => xyz is the http address of your mh server.  Needed if you want to
                         control mh from the emailed web page

Examples:

get_tv_grid -day 25 -hour 4pm -outfile my_tv.html get_tv_grid -days 7 -hour all get_tv_grid -email bruce\@misterhouse.net -mail_baseref misterhouse.net:8090

  Note on finding your provider ID:
   Enter your zip code at http://tvlistings2.zap2it.com/
   View the html source and pick the number from value='nnnnnn'
   by doing a string search for you provider.  For example:
      <OPTION value="255248">Charter Communications - Rochester</OPTION>

get_tv_grid_xmltv

Gets a TV grid/schedule from XML and changes so it to be used by the MisterHouse program to create VCR and TV event reminders. Creates a DBM for use by get_tv_info.

Configuration options for get_tv_grid_xmltv are similar to get_tv_grid. The difference is the data source for the TV schedule information.

In short, you configure XMLTV to regularly (every 24 hours) pull TV listings from SchedulesDirect, and then you feed the XML to get_tv_grid_xmltv with

tv_xml = d:/temp/tv.xml 

in the mh.ini

Example:

get_tv_grid_xmltv -infile /media/xmtv/TV.xml

Then create a scheduled task in MisterHouse

"Update TV Grid", time_cron '0 2 * * 3,6', run_voice_cmd 'Get all TV XML data'

You need a source for your TV listings in XML. One source is SchedulesDirect. Once that's configured, you will need to set up the XML using XMLTV to create the tv.xml file.

get_tv_info

Returns info about tv programs that match the requested parms. It uses a database created by the get_tv_grid program. See mh/code/bruce/tv_info.pl for examples on how to use this from mh.

Version: 1.14

Usage:

   get_tv_info [options]

    -h        => This help text
    -help     => This help text

    -channels  xyz => Will return info only for channel numbers xyz.
                      Default is all the channels found by get_tv_grid.
    -dates     xyz => Will return info only for dates xyz.
                      Default is today.  Format: month/day (e.g. 4/22).
    -times     xyz => Will return info only for shows that start at xyz.
                      Default is '6pm-10pm'.  Use 'all' for all hours.
                      Valid formats: 1 pm, 1PM, 13, 13:00.
    -early_am  xyz => Adds info for shows after midnight.
                      Formats are same as for to times.
    -increment xyz => Time increment is xyz minutes (5 or 30). Default is 5.
    -lengths   xyz => Will return info only for shows that are xyz hours long.
                      Default is any length.
    -keys      xyz => Will return info only for shows that have keywords
                      in the xyz list in their title or description.
                      Note: xyz can be a regular expression (e.g. -keys "^ER$")
    -keyfile   xyz => List of keys to search for, from a file in the data directory

      All of the above parms support these formats:
         : comma-separated values (e.g. -dates 7/4,7/5,7/6)
         : - delimited ranges     (e.g. -dates 7/4-7/6)
         : + adder spec           (e.g. -dates 7/4+2)
           Starting spec is optional (e.g. -dates +2)

    -debug        => turn on debug info
    -quiet        => turn off normal errata

Examples:

get_tv_info -channels "4-12" -lengths 2 get_tv_info -channels "4,6,12" -times "7 pm" get_tv_info -dates "7/4-7/11" -keys "star trek, er ,dilbert" get_tv_info -dates +14 -keys computer get_tv_info -time "17-23"

  Shows which have already started are excluded unless you search
  without specifying -times or you search for -times 'all'.

get_url

Gets a web page and echoes it to STDOUT or a local file.

Usage:

    get_url URL [local_file]

If local_file is specified, data is stored there, otherwise it is echoed to STDOUT.

Options are:

     -quiet: no output on stdout

     -cookies 'cookiestr': Uses the specified cookie string for the request.
      The format of 'cookiestr' should be like this: 'name1=val1; name2=val2'.

     -cookie_file_in  'file':  Like the -cookies option, but string is sent via a file.

     -cookie_file_out 'file':  Generates a cookies string from the resulting web request.

     -userid 'userid'    :  Use these 2 parms if your web page is protected by

     -password 'password':  'basic credentials' (i.e. you get a browser popup).

     -post 'poststr': Makes this a post request with the specified name/value pairs
      as the form data, such as: 'name1=val1&name2=val2'

     -header 'header_file': HTTP headers from the server are stored in this file

Examples:

get_url http://marketing.cbs.com/lateshow/topten/ $f_top10_html;

get_weather

Gets weather info NOAA web servers.

Usage:

    get_weather [options]

Options:

    -h         => This help text
    -help      => This help text

    -city     xyz => xyz is the City  you want.
    -state    xyz => xyz is the State you want.

    -data     xyz => xyz is either conditions, forecast, or all.  Default is all.

    -refresh  xyz => xyz is the number of minutes old the cached data can
                     before it will be refreshed from the net.
                     The default is 60 minutes.

    -no_log       => Unless this option is used, the results also get filed
                     into the mh/data/web directory

Example:

get_weather -city Rochester -state MN

Here is an example MisterHouse event for calling get_weather as a background process using the 'run' function:

  $v_get_internet_weather_data  = new  Voice_Cmd('Get internet weather data');
  $v_show_internet_weather_data = new  Voice_Cmd('Show internet weather data');
  if (said  $v_get_internet_weather_data) {
     run "get_weather -city $config_parms{city} -state $config_parms{state}";
     set_watch $f_weather_forecast;
  }
  if (said  $v_show_internet_weather_data or changed $f_weather_forecast) {
     print_log "Weather data displayed";
     display name $f_weather_forecast;
     display name $f_weather_conditions;
  }

house

This is a simple shell that echoes whatever you type into the 'xcmd_file'. The name of the 'xcmd_file' is specified in mh.ini. If MisterHouse detects this file, it will read and execute its contents, then delete it.

Examples:

house speak hi there house display c:\autoexec.bat house Turn the backyard light on house XA1AJ

The last example will fire trigger an X10 command, but only if you have an item defined that matches that data (e.g. X10 A1 in the above example).

ical_load

Reads an icalendar calendar file from the Unix ical program. Optionally creates a MisterHouse code file to implement calendar events.

See outlook_read for a Windows solution.

Version: 1.0

Usage:

    ical_load [options]

Options:

    -help    -> help text

    -calendar_file xyz-> Location of .calendar file. It defaults to $HOME/.calendar.
    -quiet            -> do not echo data to STDOUT
    -debug            -> print out debug

    -pl_file xyz      -> Write out a mh perl code file.  These are the various
                         formats of Calendar subjects:

                         vcr channel_num show_name (e.g. VCR 8 Dilbert)
                         voice_command  (e.g. Christmas lights on)
                         message_to_speak (e.g. Today is national geek day)

                         Note:  If the text is not a vcr or voice_command, it
                                will be treated as a messages.

    -date mm/dd/yy    -> Get data with a start_time on date.  Default is today.
    -days ###         -> Look out ### days from -date.  Default is none, today only.

Examples:

ical_load -help ical_load -calendar_file /home/dbl/.calendar -pl_file /projects/mhcode/calendar_events.pl ical_load -calendar_file /home/dbl/.calendar -date 11/07/00 -days 2 ical_load -calendar_file /home/dbl/mh/data/calendar ical_load

mhl

A Unix script you can use to start MisterHouse (rather than calling mh directly) to help ensure that MisterHouse will always be running. This is a simple shell will restart MisterHouse if it detects that mh exited abnormally. You can pass in the same startup parms to mhl as you us for mh.

On windows, this function is built into the mh.bat script.

net_ftp

Sends, receives, or deletes a file to remote site via ftp. There is also an identical net_ftp function, if you want to call it directly from MisterHouse.

Usage:

    net_ftp -option value -option value ...
Where -option can be any of the following:
       server          Default is mh.ini parm net_www_server
       user            Default is mh.ini parm net_www_user
       password        Default is mh.ini parm net_www_password
       dir             Default is mh.ini parm net_www_dir

       file            Name local/remote file to get/put
       file_remote     Name of remote file (if different from file)
       command         get/put/delete.
       type            ASCII/binary  (default is ASCII)
       passive         0/1.  Default is 0
       timeout         Defaults to 20 (seconds)

Example:

net_ftp -command put -file junk1.txt -file_remote /tmp/junk1.txt

outlook_read

Reads an MS Outlook (a windows mail/calendar program) folder data and optionally creates a MisterHouse code file to implement calendar events.

See ical_load for a Unix solution.

Usage:

    outlook_read [options]

Options:

    -help    -> help text

    -version xyz -> Version of Outlook.  Use 98 if you have Outlook 98.

    -quiet       -> do not echo data to STDOUT
    -debug       -> print out debug

    -folder xyz  -> Get data from folder xyz.  It can be one of the following:
                      Deleted, Outbox, SentMail, Inbox, Calendar (default),
                      Contacts, Journal, Notes, Tasks

    -pl_file xyz -> Write out a mh perl code file.  These are the various
                    formats of Calendar subjects:

                      vcr channel_num show_name (e.g. VCR 8 Dilbert)
                      voice_command  (e.g. Christmas lights on)
                      message_to_speak (e.g. Today is national geek day)

                    Note:  If the text is not a vcr or voice_command, it
                           will be treated as a messages.

    -date xyz    -> Get data with a start_time on date xyz.  Default is today.
    -date_end xyz-> Get data with a start_time between -date and -date_end
    -days xyz    -> Look out xyz days from -date.  Default is 1 day.

Examples:

outlook_read -help outlook_read -date 1/17 outlook_read -date 12/25/97 -days 2 outlook_read -pl_file /projects/mhcode/outlook_events.pl outlook_read

report_weblog

report_weblog reads MisterHouse and/or Apache server logs and generates report graphs and optionally email them.

Usage:

  report_weblog [options] logfile(s)

    -h        => This help text
    -help     => This help text

    -ignore    xyz => A comma-delimited list of ip address to ignore.

    -mailto     xyz => Will email the charts to xyz
    -mailserver xyz => xyz is the SMTP host.  Default is localhost

    -runid      xyz => All graphs will have xyz as a prefix.  Default is blank.
    -outdir     xyz => All graphs be stored in directory xyz.  Default is .

Examples:

report_weblog -mailto 'bruce@misterhouse.net' /var/log/httpd/access_log report_weblog -mailto winters@home.net -mailserver 24.2.1.70 e:/mh/data/logs/server.1999_07.log

mhsend

Allows you to send data to MisterHouse over the intra/internet. Data can be logged, filed, spoken, displayed, or run. The data processed by mh/code/common/mhsend_server.pl

The following flags control what the companion mh server.pl code does:

    -file xyz    -> Files the data into mh/data/mhsend/xyz

    -log xyz     -> Logs  the data into mh/data/mhsend/xyz.log

    -run         -> Runs the data as command.

    -display xyz -> Displays the data.  xyz is how log to leave the display up.

    -speak       -> Speaks and displays the data.

    -pwfile xyz  -> Points to a password file.

Usage:

    mhsend 'hi there'
    mhsend -display 60 hi there Bruce
    mhsend -port 8083 -host misterhouse.net 'hi there'
    mhsend -speak file_to_speak.txt
    mhsend -file file1 file_to_send.txt
    mhsend -log This is a good URL:  http://goodplace.com
    echo 'hi there' | mhsend -stdin
monitor_weblog
monitor_weblog monitors a Apache server log file. When the server logs hits, this code will summarize them and pass them onto the MisterHouse speak_server.pl code via a tcp/ip socket.

Usage:

  monitor_weblog [options] logfile

    -h        => This help text
    -help     => This help text

    -mh_server xyz => The ip address of your MisterHouse box.
    -mh_port   xyz => The ip port you set mh.ini server_speak to.
    -ignore    xyz => A comma-delimited list of ip address to ignore.

Examples:

monitor_weblog -mh_server house -ignore 'house,10.0.0.1' /var/log/httpd/access_log

set_clock

Sets the clock according to the time from an internet connected NIST atomic clock server. Instead of requiring accurate time zone information, set_clock will simply set the time minute and second, but will keep to the nearest hour it was already set to.

Usage:

    set_clock [options]

Options:

    -h         => This help text
    -help      => This help text

    -no_set    => Do NOT set the clock, only list the difference in time.

    -ignore xyz=> Do NOT reset the local clock if the time is more then xyz minutes off.
                  Default=10

    -method xyz=> xyz can be inet_time, http, or socket.  Default is socket.

    -server xyz=> xyz is the server to get the clock data from.  Here are a few:
                    time-a.timefreq.bldrdoc.gov:14  (default)
                    time.nist.gov:??
                    time-nw.nist.gov:??

Example:

set_clock set_clock -server time-a.timefreq.bldrdoc.gov:14

More info about NIST clock servers if available here Here is an example call from MisterHouse. Since this is typically quick, we do it here with a 'do' instead of a call with Process_Item:

   if (time_cron '7 6 * * * ') {
     my $status = do "$Pgm_Path/set_clock";
     speak $status unless $Save{sleeping_parents};
   }

set_password

Creates and/or queries the MisterHouse password file, using the crypt function. If this password is set, then various menus (e.g. web, telnet, wap) will prompt for it. By default, the MisterHouse setup web pages can only be controlled with the admin logon, but you can add/delete other commands by adding authority=admin to the password_allow file. You can also specify authority with the set_authority item method, or by adding it to your web/bin xyz.pl file # Authority=user comment.

The crypt function limits the password to 8 characters. If -user is not specified, it defaults to family.

Usage:

    set_password [options]

Options:

    -h         => This help text
    -help      => This help text

    -check     => Will check, not set, the password.  Turned on if -pw_file does not exist.

    -user xyz     => xyz is the user to set the password for.

    -password xyz => xyz is the password to check.
                     If not used, a TK popup window will prompt for it.

    -pw_file xyz  => xyz is the file that the crypt-ed password is read/written to.
                     Default is mh/data/.password

Examples:

    set_password  -user admin
    set_password  -user family -password xyz

speak

Passes the file or text to MisterHouse. It simply runs the house program.

Example:

    speak "Boo, did I scare you?"
Clone this wiki locally