Sunday, March 25, 2012

ActiveX ActivePerl DTS Task

I need help with executing an ActiveX Perl DTS Task.

I have ActivePerl installed and I do not get a task error when I run it. The script works perfectly when I run it from a command prompt. The problem is that the task will not extract the files from the tar file.

sub Main()
{
#using modules
use Archive::Tar;
use Compress::Zlib;

#create a new tar archive object
my $tar = Archive::Tar->new;

#set the name of the compressed files
$main_tar = "C:\Inetpub\wwwroot\legacyrealestate\db\DW168E.tmp. tar";

#read the main tar file and extract files
$tar->read($main_tar,1);
$tar->extract();

return 0; # DTSTaskExecResult_Success;
}

Any clue?I think I know why it appears that it wasn't working. It worked but not like I expected. It extracted the files into the default sql server directory.

So My next question is how do specify the directory to extract to?

Originally posted by jcochran2003
I need help with executing an ActiveX Perl DTS Task.

I have ActivePerl installed and I do not get a task error when I run it. The script works perfectly when I run it from a command prompt. The problem is that the task will not extract the files from the tar file.

sub Main()
{
#using modules
use Archive::Tar;
use Compress::Zlib;

#create a new tar archive object
my $tar = Archive::Tar->new;

#set the name of the compressed files
$main_tar = "C:\Inetpub\wwwroot\legacyrealestate\db\DW168E.tmp. tar";

#read the main tar file and extract files
$tar->read($main_tar,1);
$tar->extract();

return 0; # DTSTaskExecResult_Success;
}

Any clue?|||This is really a perl question but I would try setting the directory by using the SetCwd(directory) command.|||Thanks I will try that.|||I keep getting a "Function not found" error. Can anybody give me a peice of sample code using Win32::SetCwd()?|||Here is the updated perl script.

#using modules
use Archive::Tar;
use Compress::Zlib;
use Win32::File;

sub Main()
{
#create a new tar archive object
my $tar = Archive::Tar->new;

#set the name of the compressed files
$main_tar = "C:\Inetpub\wwwroot\legacyrealestate\db\DW168E.tmp. tar";
$res_tar = "ListingsRESIDENTIAL-Residential.txt.gz";

# set the directory
$dir = "C:\Inetpub\wwwroot\legacyrealestate\db\";
Win32::SetCwd($dir);

#read the main tar file and extract files
$tar->read($main_tar,1);
$tar->extract();

return 0; # DTSTaskExecResult_Success;
}

No comments:

Post a Comment