Index: /trunk/ippScripts/scripts/magic_definerun.pl
===================================================================
--- /trunk/ippScripts/scripts/magic_definerun.pl	(revision 20688)
+++ /trunk/ippScripts/scripts/magic_definerun.pl	(revision 20689)
@@ -43,8 +43,8 @@
 
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
-pod2usage( -msg => "Required options: --exp_id --workdir",
+pod2usage( -msg => "Required options: --warp_id --workdir",
            -exitval => 3) unless
-    defined $exp_id and
-    defined $workdir;
+    defined $workdir and
+    defined $warp_id;
 
 # $ipprc->define_camera($camera);
@@ -54,4 +54,5 @@
 my $magictool = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
 my $difftool  = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
+my $warptool  = can_run('warptool') or (warn "Can't find warptool" and $missing_tools = 1);
 if ($missing_tools) {
     warn("Can't find required tools.");
@@ -60,4 +61,24 @@
 
 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
+
+if (!$exp_id) {
+    my $command = "$warptool -warped -warp_id $warp_id -limit 1";
+    $command .= " -dbname $dbname" if defined $dbname;
+    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => $verbose);
+    unless ($success) {
+        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
+        &my_die("Unable to perform warptool -warped error_code: $error_code", $error_code);
+    }
+
+    my $warptool_output = join "", @$stdout_buf;
+
+    my $warpskyfiles = parse_md_fast($mdcParser, $warptool_output);
+    &my_die("Unable to parse metadata list", $PS_EXIT_UNKNOWN_ERROR) unless $warpskyfiles;
+
+    my $warped = $warpskyfiles->[0];
+    $exp_id = $warped->{exp_id};
+    &my_die("failed to get exp_id for warp: $warp_id", $PS_EXIT_UNKNOWN_ERROR) unless $exp_id;
+}
 
 ### Get a list of inputs
