Running programs in perl

I am trying to run a program called GMT using perl. Cannot make to run. I have tried using exec("date"); as a test but when I use exec($try); nothing happens.

#!/usr/bin/perl

  print "$#ARGV\n";

  if ($#ARGV != 3) {
      print "usage: jcdplot.perl\n";
      exit;
  }

  $h = $ARGV[0];

# Get arguments when user includes them
# Change annotation if depth variation in plot gets too large
  $dz = 25.0;
  $zdif = 50.0;
  if ( $#ARGV == 3 ) {
      $zmin = $ARGV[0];
      $zmax = $ARGV[1];
      $vmin = $ARGV[2];
      $vmax = $ARGV[3];
      $dz = $zmax - $zmin;
      print "dz $dz $zdif";
      if ( $dz > $zdif ) {
          $annot = "a10.0f1.0";
          print " a10.0f1.0\n";
      }
      else {
          $annot = "a1.0f0.5";
          print " a1.0f0.5\n";
      }
  }

# Title and description of travel time plotting axes
  $TITLE = "JCD Model S sound speed (red) and interpolated (black)";
  $ZDESC = "Depth, z, Mm";
  $VDESC = "Sound speed, v, Mm/min";

  $try = "psxy jcd.vtab -JX10i/5.5i -R-0.5/25/-0.5/5 -Wred -Ba1.0f0.5:$ZDESC:/a1.0f0.5:$VDESC::.$TITLE:WSne -m -K > jcdint.ps";
  print "TRY: $try\n";

# No arguments to script
  if ( $#ARGV == 3 ) {
    exec("date");
  }
  exec($try);

How do you figure out nothing happens ?

Seems like your command redirects the output to "jcdint.ps". Do you see it created after execution of the Perl program ?

Run the following on the shell prompt and see if "jcdint.ps" was created/written into. I'd assume this is what your Perl program is trying to execute.

psxy jcd.vtab -JX10i/5.5i -R-0.5/25/-0.5/5 -Wred -Ba1.0f0.5:Depth, z, Mm:/a1.0f0.5:Sound speed, v, Mm/min::.JCD Model S sound speed (red) and interpolated (black):WSne -m -K > jcdint.ps

Also, remove the redirection part "> jcdint.ps" and see if it executes without error on the shell prompt first.

tyler_durden