Demo Discussion
Forum Config Examples Contributions Vulnerabilities
  Contributions to ELOG, Page 4 of 6  Not logged in ELOG logo
ID Date Author Author Email Categoryup Subject Status Last Revision
  17   Mon Oct 10 18:47:09 2005 Exaos LeeExaos.Lee@gmail.comScriptHow to run elogd on Gentoo LinuxStableTue Oct 11 08:06:55 2005 by Stefan Ritt
I have created some scripts for running elogd on Gentoo Linux. Please untar the attachment and read the file "elogd_gentoo_readme". Any comment is welcomed.
Attachment 1: elogd_gentoo.tar.gz
  20   Wed Jan 10 23:08:27 2007 Exaos LeeExaos.Lee@gmail.comScriptScript for running ELOGD on Ubuntu LinuxStable 
I prepared one init script for ELOGD running on Ubuntu Linux.
Please see the attachment.
Attachment 1: elogd_ubuntu.tgz
  27   Tue Jan 29 23:18:39 2008 Diogo Alvesdiogomiguelalves@gmail.comScriptMultiple file upload for FirefoxStableWed Jan 30 07:56:53 2008 by Stefan Ritt

Here's a firefox extension that works extremely well if one uses drag n'drop to upload several attachment files at once:

 

https://addons.mozilla.org/en-US/firefox/addon/219

 

  29   Thu Nov 27 11:43:32 2008 T. Ribbrockemgaron+elog@ribbrock.orgScript/etc/init.d/elog script for Debian-like distrosStable 

The attached script was used by the Debian package (which is no longer maintained) to start/stop elogd. I have changed it based on some comments in the forum (see script) to add some more functionality. As there is no mainatined elog package for Debian anymore, I'm placing it here in the hope that it might come in handy for users who want to run elog under Debian.

This script needs to be placed in /etc/init.d and expects elogd to be installed as /usr/sbin/elogd (can be changed, of course).

Attachment 1: elog
#!/bin/sh
# Init script for ELOG.
# Copyright © 2003, 2005  Recai Oktaş <roktas@omu.edu.tr>
#
# Additional changes by Thomas Ribbrock <emgaron@ribbrock.org>
# - 2008-11-27: Added better reload functionality, based on suggestion and
#   code from Yoshio Imai as posted in elog forum
#
# Licensed under the GNU General Public License, version 2.
# See the file `http://www.gnu.org/copyleft/gpl.txt'.

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/elogd
NAME=elogd
DESC="ELOG daemon"

test -f $DAEMON || exit 0

set -e

# Admin should be able to lock some options.
if [ -f /etc/default/elog ]; then
	. /etc/default/elog
fi

# To be in the safe side, the followings should be always defined.
PIDFILE=${PIDFILE:-/var/run/$NAME.pid}
CONFFILE=${CONFFILE:-/etc/elog.conf}

# Add the options to argument list only if defined previously.  Since
# some options may also be present in the conffile, we couldn't preset
# those options which would otherwise overwrite the settings in the
# conffile.  Also note that, all have reasonable compiled-in defaults.
ARGS="${PIDFILE+"-f $PIDFILE"}         \
      ${CONFFILE+"-c $CONFFILE"}       \
      ${LOGBOOKDIR+"-d $LOGBOOKDIR"}   \
      ${RESOURCEDIR+"-s $RESOURCEDIR"} \
      ${PORT+"-p $PORT"}               \
      ${HOST+"-n $HOST"}               \
      ${VERBOSE+"-v"}"
      
# Always run as a daemon.
ARGS=`echo $ARGS -D`

case "$1" in
	start)
		echo -n "Starting $DESC: "
		start-stop-daemon --start --quiet --pidfile $PIDFILE \
			--exec $DAEMON -- $ARGS 2>&1
		sleep 1
		if [ -f "$PIDFILE" ] && ps h `cat "$PIDFILE"` >/dev/null; then
			echo "$NAME."
		else
			echo "$NAME failed to start; check syslog for diagnostics."
			exit 1
		fi
		;;
	stop)
		echo -n "Stopping $DESC: $NAME"
		start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE \
			--exec $DAEMON -- $ARGS 2>&1
		echo "."
		;;
	reload)
		# Send HUP signal to reload config file
		# (Only needed if config is edited manually and not via
		# webinterface)
		if [ -f $PIDFILE ]; then
			echo -n "$DESC to reread config file ... "
			kill -HUP `cat "$PIDFILE"`
			echo "done"
		else
			echo "No $PIDFILE found!"
		fi
		;;
	restart|force-reload)
		$0 stop
		sleep 1
		$0 start
		if [ "$?" != "0" ]; then
			exit 1
		fi
		;;
	*)
		N=/etc/init.d/$NAME
		echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
		exit 1
		;;
esac

exit 0

# vim:ai:sts=8:sw=8:
  30   Mon Jul 20 14:23:56 2009 Stefan Rittstefan.ritt@psi.chScriptDoing mathematical calculations with attributesStable 

Following entry was written by Richard Stamper. I moved it here for persistency:

On the matter of automatic calculation of fields, it is possible using included javascript but you have to do the work yourself.  For example, we have a log which computes responsivity as the ratio of a photocurrent and optical power.  With log attributes called "Photocurrent", "Optical Power" and "Responsivity" there is a file in the logbooks directory called photomixer_javascript.html containing something like:

<script>

if (document.form1.Photocurrent) {
  document.form1.Photocurrent.onchange = new Function(
    "mod();"+
    "var power = parseFloat(
document.form1.Optical_Power.value);"+
    "var current = parseFloat(
document.form1.Photocurrent.value);"+
    "if (!isNan(power) && !isNan(current) && power != 0.0) {"+
    "  
document.form1.Responsivity.value = Math.round(current/power*100)/100.0"+
    "}"
    );

  document.form1.Optical_Power.onchange = document.form1.Photocurrent.onchange;
}

</script>

and the elogd.cfg file includes

Bottom text = photomixer_javascript.html

for the relevant log.

The assignments to the onchange handlers are guarded because this javascript is included on all pages for that log, including the list pages where there is no such field as Photocurrent, (or Optical_Power) and the event handler function is defined dynamically for the same reason.

 

  39   Fri Sep 17 06:19:39 2010 Stefan Rittstefan.ritt@psi.chScriptCustom input forms implementationStableThu Jul 2 20:55:55 2015 by Stefan Ritt

Dear ELOG users,

starting with SVN revision 2328, custom input forms are implemented. This allows application specific formats for check lists etc. In our specific case we had to implement a shift check list, which was quite long. Furthermore the check list should be optimized for an iPad, which we take in the field and record various checks and readings (in our case some gas pressure gauges at the PSI particle accelerator). Since the standard ELOG interface was too inflexible, a completely hand-written form was needed. The form can be activated by the new configuration options Custom New Form, Custom Edit Form and Custom Display Form, one for a new entry, an entry to edit and and entry to display. In our case we used the same form for all three cases. This is how the shift check list looks under the Safari Browser on a PC:

Capture.png

And here is how it looks on the iPad:

IMAG0036.jpg

Each section can be collapsed and expanded (blue arrows at the left), and various internal checks are made before the check list can be submitted.

Implementing such forms is however more something for the advanced user, since you have to hand-write HTML with CSS and JavaScript code. It can then however be a powerful method for check lists. Please find in the attachments the elogd.cfg configuration for that logbook and the shiftcheck.html source code file. It is a bit complicated since the page is a static page, elogd just serves it from the file. This requires all the dynamic functions to be implemented inside the HTML file with JavaScript. To display an entry for example, the JavaScript loads the raw data with the "?cmd=Download" command and the populates the form fields. The collapsing and expanding is done by using CSS properties. The integrated style sheet was optimized for the rendering on an iPad. Rather large fonts were chosen so that the items can be checked easily with your finger tips. Various parameters are sent between the browser and the elogd program via hidden fields and cookies. So only something for experts! But if you go through the effort and hand-write the form, it can be very handy. Note that you have to upgrade to SVN revision 2328 for the three new options.

 

Attachment 2: elogd.cfg
[global]
Port = 8080
Password file = passwd

[ShiftCheck]
Comment = Shift Check List

Attributes = Author, D, M, Y, Shift, a1, a2, a3, a4, a5, h1, h2, h3, h4, h5, c1, c2, c3, c4, c5, c6, c7, bb1, cr1, cr2, cr3, cr4, cr5, cr6, cr7, cr8, cr9, cr10, cr11, cr12, cr13, cr14, cr15, cr16, cr17, cr18, cr19, cr20, cr21, cr22, cr23, cr24, cr25, cr26, sw1, sw2, sw3, sw4, sw5
Quick filter = Shift, Author
Options Shift = Morning, Evening, Night

Enable attachments = 0
Show text = 0
Custom new form = /home/meg/meg/online/elog/shiftcheck.html
Custom edit form = /home/meg/meg/online/elog/shiftcheck.html
Custom display form = /home/meg/meg/online/elog/shiftcheck.html
List after submit = 1
Attachment 4: shiftcheck.html
Attachment 5: sc_up.png
sc_up.png
Attachment 6: sc_down.png
sc_down.png
  35   Tue May 24 22:43:38 2011 JacekKdoctor99@poczta.onet.plScriptJavascript verification of simple attributes with regexpBetaTue May 24 22:46:38 2011 by JacekK

Hi,

I added possibility for a new verification of required fields in generated Javascript "function chkform()". To do this I added new logbook option "ValidPattern", in which you can set regular expression for an attribute, for example

ValidPattern HexDigits=[0-9a-fA-F]+

If there is a pattern set for required field, then in chkform() function is generated additional verification, if value of the field matches validation regexp.

Changes I made should not decrease performance of elogd. Let me know please if you can add it to regular version.

 

Jacek

Attachment 1: JScriptREVerify.patch
Index: elogd.c
===================================================================
--- elogd.c	(revision 2414)
+++ elogd.c	(working copy)
@@ -74,6 +74,8 @@
 char attr_list[MAX_N_ATTR][NAME_LENGTH];
 char attr_options[MAX_N_ATTR][MAX_N_LIST][NAME_LENGTH];
 int attr_flags[MAX_N_ATTR];
+/** Validation pattern for attribute, to test if it contains expected value */
+char attr_valid_pattern[MAX_N_ATTR][NAME_LENGTH];
 
 char attr_list_default[][NAME_LENGTH] = { "Author", "Type", "Category", "Subject", "" };
 
@@ -7033,7 +7035,7 @@
 
 int scan_attributes(char *logbook)
 /* scan configuration file for attributes and fill attr_list, attr_options
- and attr_flags arrays */
+ and attr_flags and attr_valid_pattern arrays */
 {
    char list[10000], str[NAME_LENGTH], str2[NAME_LENGTH], type[NAME_LENGTH],
        tmp_list[MAX_N_ATTR][NAME_LENGTH];
@@ -7062,11 +7064,20 @@
          }
       }
 
-      /* get options lists for attributes */
+      /* get options lists and validation patterns for attributes */
       memset(attr_options, 0, sizeof(attr_options));
+      memset(attr_valid_pattern, 0, sizeof(attr_valid_pattern));
       for (i = 0; i < n; i++) {
          n_options = 0;
 
+         sprintf(str, "ValidPattern %s", attr_list[i]);
+         if (getcfg(logbook, str, list, sizeof(list)))
+         {
+            strncpy(attr_valid_pattern[i], list, sizeof(attr_valid_pattern[i])-1);
+            attr_valid_pattern[i][sizeof(attr_valid_pattern[i])-1] = 0;
+            attr_flags[i] |= AF_HAS_VALID_PATT;
+         }
+
          sprintf(str, "Options %s", attr_list[i]);
          if (getcfg(logbook, str, list, sizeof(list)))
             n_options = strbreak(list, attr_options[i], MAX_N_LIST, ",", FALSE);
@@ -9650,6 +9661,17 @@
             rsprintf("    document.form1.%s.focus();\n", ua);
             rsprintf("    return false;\n");
             rsprintf("  }\n");
+            if (attr_flags[i] & AF_HAS_VALID_PATT) 
+            {
+              sprintf(str, loc("var validPatt=new RegExp(\"%s\");"), attr_valid_pattern[i]);
+              rsprintf("  %s\n", str);
+              rsprintf("  if (!validPatt.test(document.form1.%s.value)) {\n", ua);
+              sprintf(str, loc("Invalid value for attribute '%s'"), attr_list[i]);
+              rsprintf("    alert(\"%s\");\n", str);
+              rsprintf("    document.form1.%s.focus();\n", ua);
+              rsprintf("    return false;\n");
+              rsprintf("  }\n");
+            }
          }
       }
 
Index: elogd.h
===================================================================
--- elogd.h	(revision 2414)
+++ elogd.h	(working copy)
@@ -192,6 +192,7 @@
 #define AF_MUSERLIST         (1<<13)
 #define AF_USEREMAIL         (1<<14)
 #define AF_MUSEREMAIL        (1<<15)
+#define AF_HAS_VALID_PATT    (1<<16)
 
 /* attribute format flags */
 #define AFF_SAME_LINE              1
  36   Tue Aug 23 12:07:51 2011 Stefan Rittstefan.ritt@psi.chScriptRe: JavaScript list auto-refreshStableTue Jul 12 12:36:16 2005 by Emiliano Gabrielli

Emiliano Gabrielli wrote:
Here is a simple piece of JS code to accomplish a smart page reload.
We don't reload if in some kind of editing mode.

You can put the code everywhere you like in the elog html page, my suggestion is to put it in Bottom Text (or Top Text):

;auto-refresh
Bottom text = [I]<script language="JavaScript">if (null==window.location.href.match('/[0-9]+$|.*(cmd|select)=.*') ) { window.setTimeout("location.reload();", 2*60*1000); now=new Date(); document.write('<br/>Last reload at '+now.getFullYear()+'/'+(now.getMonth()+1)+'/'+now.getDate()+', '+( ((h=now.getHours())<10) ? '0'+h :h)+':'+( ((m=now.getMinutes())<10) ? '0'+m :m)+':'+( ((s=now.getSeconds())<10) ? '0'+s :s)) }</script>[/I]


the timer is a product of # of minutes, #of seconds and milliseconds... 2 minutes in the above example Smile



Revision Tue Jul 12 12:36:16 2005 wrote:

modified regular expression in order to not activate the auto-refresh in the signle entry view


Starting with SVN revision 2422, there is a new config option

refresh = <seconds>


which lets you do the same thing.
  37   Tue Aug 23 19:45:16 2011 Stuart Wilkinsswilkins@bnl.govScriptELOG Mail ParserAlpha 

 Hi!

I have attached a small script which can process an e-mail and submit this e-mail as a log entry. This is alpha at the moment but if you have suggestions or find bugs please let me know. 

The easiest way to process this is to use the ".forward" file in unix. If this file contains the line:

| "/usr/bin/python /home/tardis/elogmail/process.py --log /home/tardis/elogmail/mail.log -r -u http://localhost:8080/TARDIS -a Category=email -a Type=Log"

This will pipe the incoming mail to the e-log running on the localhost with the experiment TARDIS. Attributes can be set using the "-a" switch like in the elog command line utility. To get help with all the options please run the script with the command:

python process.py -h

which will give help.

Any questions, please don't hesitate to contact me, and I will do my best to help.

Thanks again to Stefan for a great application.

Best wishes,

Stuart

 

Attachment 1: process.py.gz
Attachment 2: forward.gz
  38   Fri Sep 9 12:08:26 2011 Andreas Luedekeandreas.luedeke@psi.chScriptcreate incremental daily backups of logbooks for Unix/LinuxBeta 
A very simple backup utility for elog logbooks.
If you want to recover your logbook from corrupted entries, an incremental backup comes in handy:
you can just replace the corrupted files with the previous versions.
Below is a very simple wrapper to create backups of the logbook into some local directory (/logbooks_backup in
the example script). The second wrapper lists the files in a given ".tar" archive.

You would run the backup from a cron job with the line:
1 0 * * * /usr/local/elog/elog_backup_daily

This will create daily backups of modified logbook and config files and a weekly backup of the password file
/usr/local/elog/passwd.txt (if you wonder why: our passwd.txt file has more than 1 MByte and of course it
changes with every login).

elog_backup_daily (copy to /usr/local/elog) script to create tar file and remove tar files older than 90 days
exclude-logbooks  (copy to /usr/local/elog) list of files to be excluded in backup (thumbnails, etc.) 
elog_backup_listfiles (copy to /usr/local/bin) shows content of a given tar file (omits directories in list)
Attachment 1: elog_backup_daily
#!/bin/sh
# source file directory
srcd=/usr/local/elog/

# backup all files newer than 25 hours
date=$(date -d "-25hours" "+%Y%m%d %H:%M")
# backup file directory
tard=/logbooks_backup
# backup tar file name
tarf=$tard/$(date +%Y%m%d_%a.tar)
# do not backup files that match patterns in this file
excf=/usr/local/elog/exclude-logbooks
# create backup
cd $srcd
tar --ignore-case -X $excf --newer "$date" -cf $tarf . logbooks/*

# copy passwd.txt
if [ "$(date +%u)" -eq 1 ]
then
	passwd=$tard/passwd_$(date +%Y%m%d_%a.txt)
	cp $srcd/passwd.txt $passwd
	gzip -9 $passwd
fi
# delete all backups older than 90 days
find $tard -mtime +90 -name "*_???.tar"           -exec rm -f {} +
find $tard -mtime +90 -name "passwd_*_???.txt.gz" -exec rm -f {} +
Attachment 2: exclude-logbooks
*.png.png
*.gif.png
*.jpg.png
*.pdf.png
oldLogbooks/*
logbooks/elog.log
passwd.txt
ssl/*
logbooks/Backup/*
logbooks/old/*

Attachment 3: elog_backup_listfiles
tar -tf $1|grep -v "^.*/$"
ELOG V3.1.5-2eba886