Index: trunk/ippScripts/scripts/sc_prepare_diff.pl
===================================================================
--- trunk/ippScripts/scripts/sc_prepare_diff.pl	(revision 38097)
+++ trunk/ippScripts/scripts/sc_prepare_diff.pl	(revision 38168)
@@ -18,16 +18,9 @@
 use Pod::Usage qw( pod2usage );
 
-# Hard coded values
-# my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
-my $remote_root     = '/scratch3/watersc1/';
-my $remote_hostname = "LANL/Mustang";         # Name of the remote node.
-my $threads_req     = 4;                      # How many threads are we going to use?
-
-my $fail_state = "prep_fail";
-
 # Look for programs we need
 my $missing_tools;
 my $remotetool = can_run('remotetool') or (warn "Can't find remotetool" and $missing_tools = 1);
 my $difftool    = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
+my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
 
 if ($missing_tools) {
@@ -36,5 +29,5 @@
 }
 
-my ($remote_id,$diff_id,$camera,$dbname,$verbose,$path_base,$no_update);
+my ($remote_id,$diff_id,$camera,$dbname,$verbose,$path_base,$no_update,$cmd_recipe);
 GetOptions(
     'remote_id=s'    => \$remote_id,
@@ -42,4 +35,5 @@
     'camera|c=s'     => \$camera,
     'dbname|d=s'     => \$dbname,
+    'recipe=s'       => \$cmd_recipe,
     'path_base=s'    => \$path_base,
     'no_update'      => \$no_update,
@@ -48,10 +42,66 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --remote_id -diff_id --camera --dbname --path_base", -exitval => 3) unless
+pod2usage( -msg => "Required options: --remote_id -diff_id --camera --dbname --path_base --recipe", -exitval => 3) unless
     defined($remote_id) and
     defined($diff_id) and
     defined($camera) and
     defined($path_base) and
+    defined($cmd_recipe) and
     defined($dbname);
+
+
+# Hard coded values
+# Now accessible from a recipe
+my %remote_recipe = ();
+{
+    my $verbose = 0;
+    my $conf_cmd = "$ppConfigDump -dump-recipe REMOTE -";
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $conf_cmd, verbose => $verbose);
+    unless ($success) {
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform ppConfigDump: $error_code", -1, $PS_EXIT_SYS_ERROR);
+    }
+    my $mdcParser = PS::IPP::Metadata::Config->new;
+    my $metadata = $mdcParser->parse(join "", @$stdout_buf);
+
+    my $active_recipe = '';
+    my %recipes = ();
+    
+#    print Dumper($metadata);
+    foreach my $entry (@{ $metadata }) {
+        if (${ $entry }{name} eq 'ACTIVE') {
+            $active_recipe = ${ $entry }{value}; # Not actually used
+        }
+        else {
+            if (${ $entry }{class} eq 'metadata') { # A real recipe
+                my $name = ${ $entry }{name};
+                foreach my $tentry (@{ ${ $entry }{value} }) {
+                    if (${ $tentry }{class} eq 'scalar') { # A recipe value
+                        $recipes{$name}{${ $tentry }{name}} = ${ $tentry }{value};
+                    }
+                    elsif (${ $tentry }{class} eq 'metadata') { # A recipe array 
+                        foreach my $arr_entry (@{ ${ $tentry }{value} }) {
+                            push @{ $recipes{$name}{${ $tentry }{name}} }, ${ $arr_entry }{value};
+			}
+		    }
+		}
+	    }
+	}
+    }
+        
+    unless (exists($recipes{$cmd_recipe})) { &my_die("Cannot find recipe $cmd_recipe", -1, $PS_EXIT_CONFIG_ERROR) };
+#    print Dumper(%recipes);
+    %remote_recipe = %{ $recipes{$cmd_recipe} }; # Select the appropriate recipe.
+#    print Dumper(\%remote_recipe);
+}
+
+# my $remote_root = '/lustre/scratch1/turquoise/watersc1/ps1/'; # Far side destination base location
+my $remote_root     = $remote_recipe{REMOTE_ROOT};
+my $remote_hostname = $remote_recipe{REMOTE_HOSTNAME};         # Name of the remote node.
+my $threads_req     = 4;                      # How many threads are we going to use?
+
+my $fail_state = "prep_fail";
+
 
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $remote_id, $diff_id, $PS_EXIT_CONFIG_ERROR, $fail_state);
@@ -198,5 +248,5 @@
 	my $remote_templsourc = &uri_local_to_remote($ipp_templsourc);
 	
-	my $pre_command     = " sc_check_diff.pl --diff_id ${diff_id} --skycell_id ${skycell_id} --dbname ${dbname} --out_path_base ${remote_outroot} $remote_inimage $remote_inmask $remote_inwt $remote_insourc $remote_templimage $remote_templmask $remote_templwt $remote_templsourc ";
+	my $pre_command     = " sc_check_diff.pl --diff_id ${diff_id} --remote_root ${remote_root} --skycell_id ${skycell_id} --dbname ${dbname} --out_path_base ${remote_outroot} $remote_inimage $remote_inmask $remote_inwt $remote_insourc $remote_templimage $remote_templmask $remote_templwt $remote_templsourc ";
 
 	# make any directory we may need
