Demo Discussion
Forum Config Examples Contributions Vulnerabilities
  Discussion forum about ELOG, Page 784 of 806  Not logged in ELOG logo
ID Date Icon Author Author Email Category OS ELOG Versiondown Subject
  1929   Thu Sep 7 22:06:00 2006 Smile Arno Teunissea.teeling3@chello.nlQuestionWindows elog perl script and the command prompt and eof
hello

Just wrote a quick and dirty perl script ( See Attachment ) that let's you enter a record into the database. Put it into the directory where the config file is located. It look's at the "attributes = " and the "required attributes = "
within a section in the elog configuration file. The script is using elog.exe to accomplish this.

One problem with the script is that you must press Control_Z ( ^Z ) to store the data into the database.
Does anybody know how to prevent this ? It works also when redirecting the data into the script with a file input.txt. ( add2elog.pl confgi.cfg logbook < input.txt )

I Know this is NOT an elog question but maybe someone is happy with the script and has the answer for me.
Attachment 1: add2elog.pl
=pod

elog -h hostname [-p port] [-l logbook]
     [-w password]
     [-u username password]
     -a <attribute1>=<value1>
     -a <attribute2>=<value2>
     ...
     -f attachment1
     -f attachment2
     ...
     -m textfile | text



This little perlscript is intented to enter attributes into elog with elog.exe from 
the command line. 

The script checks the "attributes" and the "required attributes". When a required
attribute is needed the users sees a "*" after the attributes name.



=cut


if ( $#ARGV <1 ) {
	print "Usage : $0 Configfile.cfg logbookname\n"; 
  print "Assumed is that you run this in the directory below the logbooks\n";
  print "directory.\n"; 
  exit;

}


$LOGBOOK = $ARGV[1];

chomp $LOGBOOK;
print "Logbook : $LOGBOOK\n";


$INSTALLDIR='c:/program files/elog';

$LOGBOOK_DIR='c:/program files/elog/logbooks';
# $CFGFILE = 'c:/program files/elog/contacts.cfg' ; # can have multiple logbooks
$CFGFILE = $ARGV[0];
chomp $CFGFILE;
print "Config file : $CFGFILE<< \n";

open ( CFG, "< $CFGFILE") or die "could not find config file\n";

while ( <CFG> ) {
	# find the logbook section
		chomp;
	next if not /^[$LOGBOOK\]/;
	while (<CFG> ) {
		last if /^\s*[.*\]\s*$/ ; # Next section 
		if ( /^attributes\s*=\s*/i ) {
			chomp;
			s/\s*$//;
			s/^Attributes\s*=\s*//i;
			@attributes = split(/\s*,\s*/);
			#print "Found it\n";
			next;
		}elsif ( /^Required\s*Attributes\s*=\s*/i ) {
			 chomp;
			 s/\s*$//;	# remove the last white space if there is one
			 s/^Required Attributes\s*=\s*//i;
			 @RAttributes = split (/\s*,\s*/);
			 # last; # this assumes that "Required Attributes" comes after "Attributes"
    }
   }
 }
close CFG;

## Nothing usefull found , wrong config file ???
if ( scalar (@attributes) == 0 ){
	print "Nothing found\n";
	exit;
}

for ( @RAttributes ) {
		#print "==>$_<==\n";
		$RAttributes{$_} = $_ ;
}
# CHECK the RAttributes hash
#while (( $KEY, $VALUE ) = each %RAttributes ) {
#		print "Required Attribute : $VALUE\n";
#}




for ( @attributes ) { 
		print "$_ " ;
		$ATTR = $_;
	if ( exists( $RAttributes{$_} )) {
		print "* : ";
		$flag=1;
	} else {
		print ": ";
		$flag =0;
	}
	
	$HASH{$_} = <STDIN> ;
	
	chomp $HASH{$_};
	if ( $flag and $HASH{$_} eq ""  ) {
				while ( $HASH{$_} eq "" ) {
						print "This is a Required attribute\n";
						print "$ATTR * : " ;	
						$HASH{$_} = <STDIN> ;
						chomp $HASH{$_};		
		}	
	}
}


# send the info to the elog server
for ( @attributes ) { 
	print "\n -a $_=$HASH{$_}\n" ;
	if ( defined ( $HASH{$_} )) {
	
	$ATTRIBUTES .= " -a \"${_}=$HASH{$_}\"";
	#print "$ATTRIBUTES\n";
}
}

 print "\n$ATTRIBUTES\n";

print "\n";
system 	( "elog.exe -h localhost -p 80 -l $LOGBOOK $ATTRIBUTES" );
  1952   Fri Sep 22 08:55:22 2006 Reply Stefan Rittstefan.ritt@psi.chQuestionWindows Re: Attribute and checkbox
Well, what we use for such kind of check lists is the following:

Use Preset test = file.txt where file.txt contains exactly the ASCII code you mentioned, like
[ job done]  [ customer ] [ activity ] [ What should be done ]
[]            BLA          Check job1   Backup mail check
[]            BLA1         Check job2   check error report
[]            Bla2         Check job3   check MQ jobs

So one can put the "X" in the "[]" manually. I know, the individual lines are no real elog attributes, but it works nicely for some check lists. Drawback might be that a use can edit the whole text, but sometimes I find that's even a plus, since the user might add some comments.
  1960   Fri Sep 29 18:35:09 2006 Cool marta floodmarta33911@aol.comQuestion  Entering information
I am not sure how to get to the page I need to log my clinical time for school and I have no idea how I got here
Thanks,
Marta
  67   Thu Jul 11 10:36:09 2002 Reply Stefan Rittstefan.ritt@psi.chBug fix  Re: a bug and a question
>    If you have only one entry in the logbook and have it set up in threaded 
> mode like: ?cmd=Search&mode=threaded&reverse=1, when you click on the icon 
> of the entry or the number of the entry to see it, it does not allow you 
> to.  If there is more than one entry, it works fine.  

Ok, has been fixed. Will come in 2.0.5

>    Also I wanted to make a submit page from where you could either go back 
> to the logbook which you just entered a message for or type a new entry for 
> that logbook.  First of all, is there a way to have only one file called 
> submitpage.html in which I can define this for all logbooks or do i need it 
> for ever logbook.  And also, is there a way I can even set a link that will 
> allow to create a new entry.  I tried: 
>     <a href="demo/?cmd=new">Enter</a> another message<p>
> 
> but for some reason it does not work.  Is there a way to implement this?

The documentation was wrong about that which has been corrected. The proper 
file contents should be

<h1>You successfully submitted a message</h1>
<a href="?cmd=Back">Back</a> to the logbook<p>
<a href="?cmd=New">Enter</a> another message

This way one only needs one file for all logbooks.
  67   Thu Jul 11 10:36:09 2002 Reply Stefan Rittstefan.ritt@psi.chBug fix  Re: a bug and a question
>    If you have only one entry in the logbook and have it set up in threaded 
> mode like: ?cmd=Search&mode=threaded&reverse=1, when you click on the icon 
> of the entry or the number of the entry to see it, it does not allow you 
> to.  If there is more than one entry, it works fine.  

Ok, has been fixed. Will come in 2.0.5

>    Also I wanted to make a submit page from where you could either go back 
> to the logbook which you just entered a message for or type a new entry for 
> that logbook.  First of all, is there a way to have only one file called 
> submitpage.html in which I can define this for all logbooks or do i need it 
> for ever logbook.  And also, is there a way I can even set a link that will 
> allow to create a new entry.  I tried: 
>     <a href="demo/?cmd=new">Enter</a> another message<p>
> 
> but for some reason it does not work.  Is there a way to implement this?

The documentation was wrong about that which has been corrected. The proper 
file contents should be

<h1>You successfully submitted a message</h1>
<a href="?cmd=Back">Back</a> to the logbook<p>
<a href="?cmd=New">Enter</a> another message

This way one only needs one file for all logbooks.
  67   Thu Jul 11 10:36:09 2002 Reply Stefan Rittstefan.ritt@psi.chBug fix  Re: a bug and a question
>    If you have only one entry in the logbook and have it set up in threaded 
> mode like: ?cmd=Search&mode=threaded&reverse=1, when you click on the icon 
> of the entry or the number of the entry to see it, it does not allow you 
> to.  If there is more than one entry, it works fine.  

Ok, has been fixed. Will come in 2.0.5

>    Also I wanted to make a submit page from where you could either go back 
> to the logbook which you just entered a message for or type a new entry for 
> that logbook.  First of all, is there a way to have only one file called 
> submitpage.html in which I can define this for all logbooks or do i need it 
> for ever logbook.  And also, is there a way I can even set a link that will 
> allow to create a new entry.  I tried: 
>     <a href="demo/?cmd=new">Enter</a> another message<p>
> 
> but for some reason it does not work.  Is there a way to implement this?

The documentation was wrong about that which has been corrected. The proper 
file contents should be

<h1>You successfully submitted a message</h1>
<a href="?cmd=Back">Back</a> to the logbook<p>
<a href="?cmd=New">Enter</a> another message

This way one only needs one file for all logbooks.
  67   Thu Jul 11 10:36:09 2002 Reply Stefan Rittstefan.ritt@psi.chBug fix  Re: a bug and a question
>    If you have only one entry in the logbook and have it set up in threaded 
> mode like: ?cmd=Search&mode=threaded&reverse=1, when you click on the icon 
> of the entry or the number of the entry to see it, it does not allow you 
> to.  If there is more than one entry, it works fine.  

Ok, has been fixed. Will come in 2.0.5

>    Also I wanted to make a submit page from where you could either go back 
> to the logbook which you just entered a message for or type a new entry for 
> that logbook.  First of all, is there a way to have only one file called 
> submitpage.html in which I can define this for all logbooks or do i need it 
> for ever logbook.  And also, is there a way I can even set a link that will 
> allow to create a new entry.  I tried: 
>     <a href="demo/?cmd=new">Enter</a> another message<p>
> 
> but for some reason it does not work.  Is there a way to implement this?

The documentation was wrong about that which has been corrected. The proper 
file contents should be

<h1>You successfully submitted a message</h1>
<a href="?cmd=Back">Back</a> to the logbook<p>
<a href="?cmd=New">Enter</a> another message

This way one only needs one file for all logbooks.
  67   Thu Jul 11 10:36:09 2002 Reply Stefan Rittstefan.ritt@psi.chBug fix  Re: a bug and a question
>    If you have only one entry in the logbook and have it set up in threaded 
> mode like: ?cmd=Search&mode=threaded&reverse=1, when you click on the icon 
> of the entry or the number of the entry to see it, it does not allow you 
> to.  If there is more than one entry, it works fine.  

Ok, has been fixed. Will come in 2.0.5

>    Also I wanted to make a submit page from where you could either go back 
> to the logbook which you just entered a message for or type a new entry for 
> that logbook.  First of all, is there a way to have only one file called 
> submitpage.html in which I can define this for all logbooks or do i need it 
> for ever logbook.  And also, is there a way I can even set a link that will 
> allow to create a new entry.  I tried: 
>     <a href="demo/?cmd=new">Enter</a> another message<p>
> 
> but for some reason it does not work.  Is there a way to implement this?

The documentation was wrong about that which has been corrected. The proper 
file contents should be

<h1>You successfully submitted a message</h1>
<a href="?cmd=Back">Back</a> to the logbook<p>
<a href="?cmd=New">Enter</a> another message

This way one only needs one file for all logbooks.
ELOG V3.1.5-3fb85fa6