=pod elog -h hostname [-p port] [-l logbook] [-w password] [-u username password] -a = -a = ... -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 ( ) { # find the logbook section chomp; next if not /^\[$LOGBOOK\]/; while ( ) { 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{$_} = ; chomp $HASH{$_}; if ( $flag and $HASH{$_} eq "" ) { while ( $HASH{$_} eq "" ) { print "This is a Required attribute\n"; print "$ATTR * : " ; $HASH{$_} = ; 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" );