Executing DTS package from Perl

  • Hey everyone,

    Does anyone know how to run a DTS package from a perl script (using the dtsrun command)? Is this even possible?

    I couldn't find any resources on this subject...Does anyone know of any useful links?

    Thanks.


  • Never mind, I figured it out.

    If anyone is interested:

    system("dtsrun /S serverName /N \"PackageName\" /U userName /P password");

     


  • I know you said "Never mind", but here is a subroutine that I put together to will run dts for whichever package you desire.  There are references to other subroutines but I think you can get the general idea.

    It sends the output to a text file so if there is a problem, it can be tracked down.

    #------------------------------------------------------------------------

    # Subroutine: run_dts

    # Comments:   Run a Specific Data Transformation Service Package

    # Arguments:  DTS Name

    #             'Warn' or 'Error'

    # Returned:   None

    #------------------------------------------------------------------------

    sub run_dts {

      my ($dnam, $warn) = @_;

      my ($tmpfil, $cmd, $ret, @lines, $lin, $msg);

      if ($warn ne "Warn") { $warn = "Error"; }

      $tmpfil = $g_tmpDir . "del_city_dtsout.txt";

      $cmd = 'cmd /c "' . $g_binDir . 'dtsrun /S Servername /N "' . $dnam .

          '" /U Username /P Password >' . $tmpfil . '"';

      $ret = system($cmd);

      if ($ret != 0) {

        $msg = $warn . ": Error for DTS Command: $cmd!\nError Number: $ret\n";

        if (open (FIN, $tmpfil)) {

          @lines = <FIN>;

          $lin = $lines + 2;

          $msg = $msg . join("", @lines);

          close (FIN);

        }

     

        if ($warn ne "Warn") {

          &exit_msg ($msg, $lin);

        } else {

          $g_warn = 1;

          &msg_logged ($msg, $lin);

        }

      }

    }

  • This is great sblock!

    I'll try it.

    Thanks!


Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply