#!/usr/bin/perl -w # Noninteractively run a DRAO program dp with parameters from the given # script.dp, and add an entry to logs/index.html. # # Great for command line aficionados when used in combination with # transurv and replace. use DRAORed; my $use = "Use: rds script.program"; unless($#ARGV == 0){ die $use; } my $scr = $ARGV[0]; my $prog = $scr; $prog =~ s/.*\.//; # Get the program from $scr's extension. my $rdslog = "${scr}.rds"; # Run $prog with $scr as input. open(DRAOPROG, "|$prog > $rdslog") or die "Could not start $prog, outputting to $rdslog"; print DRAOPROG "#$scr\n"; close(DRAOPROG) or die "Could not close $prog"; # This is for transurv's benefit. if(system("cp $scr ~/rdses/$scr")){ warn "Could not cp $scr ~/rdses/$scr"; } # The rest is just logging... my $runnum = checklogd("${rdslog}_"); # Create the logs directory if necessary. # For some FORTRAN related reason, $rdslog includes a bunch of binary junk. # It is of questionable use, and prevents some browsers (i.e. galeon) from # displaying it. This removes the binary cruft... my $ardslog = "${rdslog}_$runnum"; if(system("strings $rdslog > logs/$ardslog")){ warn "Error with strings $rdslog > logs/$ardslog"; } else{ unlink($rdslog) or warn "Could not delete $rdslog"; } # Find $prog's logfile in $rdslog. my $proglog = `grep -a "Log file will be:" logs/$ardslog`; unless ($proglog eq ""){ chomp $proglog; $proglog =~ s/.*Log file will be: //; $proglog =~ s/\.LOG.*/.LOG/; mvlogww($proglog); } open(LOG, ">>logs/index.html") or die "Ran $prog but could not add entry to index.html"; print LOG "rds "; if(system("cp $scr logs/${scr}_$runnum")){ warn "Could not cp $scr logs/${scr}_$runnum"; } print LOG "$scr"; unless ($proglog eq ""){ print LOG " \t  ($proglog)"; } print LOG "
\n"; close(LOG) or die "Could not close index.html";