sw7104
asked on
DTS -- Passing Global Variable into Execute Process Task, Parameters field
Experts:
I have an ActiveX Script task that dynamically creates a global variable (DiffFileName), which is a path\filename string (example string=\\172.168.1.86\K$\m yfile20040 324.bak)
Next, I have an Execute Process Task which runs Winzip.
Winzip requires several params, one of which is a source path\filename.
How do I get DTS to pass the global variable into the Execute Process Task, Parameters field? (See Details below.)
THANKS!
--SW
DETAIL:
Win2000/SQL Server 2000
Actual Execute Process Task Values (using example source filename above):
Win32 Process: C:\Program Files\WinZip\WINZIP32.EXE
Parameters: -min -a -en "c:\OGL_cta_backup.zip" "DiffFileName"
Return Code: 0
Timeout: 0
Active X Task Script:
Function Main()
CurrentDate =now()
sFilename = "\\172.168.1.86\K$\myfile" & Right(Year(CurrentDate),4)
If Month(CurrentDate) < 10 Then sFilename = sFilename & "0" & _
Month(CurrentDate) Else sFilename = sFilename & Month(CurrentDate)
If Day(CurrentDate) < 10 Then sFilename = sFilename & _
"0" & Day(CurrentDate) Else sFilename = sFilename & Day(CurrentDate)
sFilename=sFilename&".bak"
DTSGlobalVariables("DiffFi leName").V alue = sFilename
Main = DTSTaskExecResult_Success
End Function
I have an ActiveX Script task that dynamically creates a global variable (DiffFileName), which is a path\filename string (example string=\\172.168.1.86\K$\m
Next, I have an Execute Process Task which runs Winzip.
Winzip requires several params, one of which is a source path\filename.
How do I get DTS to pass the global variable into the Execute Process Task, Parameters field? (See Details below.)
THANKS!
--SW
DETAIL:
Win2000/SQL Server 2000
Actual Execute Process Task Values (using example source filename above):
Win32 Process: C:\Program Files\WinZip\WINZIP32.EXE
Parameters: -min -a -en "c:\OGL_cta_backup.zip" "DiffFileName"
Return Code: 0
Timeout: 0
Active X Task Script:
Function Main()
CurrentDate =now()
sFilename = "\\172.168.1.86\K$\myfile"
If Month(CurrentDate) < 10 Then sFilename = sFilename & "0" & _
Month(CurrentDate) Else sFilename = sFilename & Month(CurrentDate)
If Day(CurrentDate) < 10 Then sFilename = sFilename & _
"0" & Day(CurrentDate) Else sFilename = sFilename & Day(CurrentDate)
sFilename=sFilename&".bak"
DTSGlobalVariables("DiffFi
Main = DTSTaskExecResult_Success
End Function
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Rather than use the Execute Process Task... Would Shelling to the winzip exe from your Active X Task accomplish your goal?
Shell "C:\Program Files\WinZip\WINZIP32.EXE -min -a -en c:\OGL_cta_backup.zip " & sFilename
dhenson
Shell "C:\Program Files\WinZip\WINZIP32.EXE -min -a -en c:\OGL_cta_backup.zip " & sFilename
dhenson
ASKER
dhenson:
Ran following script and got error:
Error Source: Microsoft VBScript runtime error
Error Descrtiption: Type mismatch: 'Shell'
-------------------------- ---------- --
Function Main()
sFilename = "\\172.168.1.86\K$\myfile2 0040324.ba k"
Shell "C:\Program Files\WinZip\WINZIP32.EXE -min -a -en c:\OGL_cta_backup.zip " & sFilename
Main = DTSTaskExecResult_Success
End Function
Ran following script and got error:
Error Source: Microsoft VBScript runtime error
Error Descrtiption: Type mismatch: 'Shell'
--------------------------
Function Main()
sFilename = "\\172.168.1.86\K$\myfile2
Shell "C:\Program Files\WinZip\WINZIP32.EXE -min -a -en c:\OGL_cta_backup.zip " & sFilename
Main = DTSTaskExecResult_Success
End Function
Shell is not available in DTS.
ahh... oops.
my bad
my bad
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If your up to using the Execute sql task instead... try this:
declare @zipfilename varchar(255)
declare @sFilename varchar(255)
declare @command varchar(255)
set @sFilename = '\\172.168.1.86\K$\myfile' + convert(varchar(50),getdat e(),112) + '.bak'
set @zipfilename = 'c:\OGL_cta_backup.zip'
set @command = 'c:\progra~1\winzip\winzip 32 -min -e ' + @zipfilename + ' ' + @sFilename
exec master..xp_cmdshell @command
If my syntax is correct, the above should unzip 'c:\OGL_cta_backup.zip' to a file named:
'\\172.168.1.86\K$\myfile2 0040324.ba k'
declare @zipfilename varchar(255)
declare @sFilename varchar(255)
declare @command varchar(255)
set @sFilename = '\\172.168.1.86\K$\myfile'
set @zipfilename = 'c:\OGL_cta_backup.zip'
set @command = 'c:\progra~1\winzip\winzip
exec master..xp_cmdshell @command
If my syntax is correct, the above should unzip 'c:\OGL_cta_backup.zip' to a file named:
'\\172.168.1.86\K$\myfile2
ASKER
This has been so frustrating. Note that I've switched to local machine and files. Also, I've tried to strip this to the bare essentials.
This command succeeds at command line, in under 1 second total run-time (file is 409 KB uncompressed):
c:\Progra~1\WinZip\WINZIP3 2.EXE -min -a -en "c:\OGL_cta_backup.zip" "C:\Documents and Settings\SWatkins\My Documents\1Projects\Ogleba yNorton\te st20040324 .bak"
Yet, when I run the following in Query Analyzer, the process just grinds away and hangs and hangs. I'm at 8 minutes plus, and still "processing".
Everything is on the local machine/drive, a 1 gig mem XP Professional box.
Thanks for all your help. I'm about to put my fist through my machine.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
declare @localfilename varchar(255)
declare @zipfilename varchar(255)
declare @command varchar(255)
set nocount on
set @localfilename = '"C:\Documents and Settings\SWatkins\My Documents\1Projects\Ogleba yNorton\te st20040324 .bak"'
set @zipfilename = '"c:\OGL_cta_backup.zip"'
--C:\Progra~1\WinZip\WINZI P32.EXE -min -a -en "c:\OGL_cta_backup.zip" "C:\Documents and Settings\SWatkins\My Documents\1Projects\Ogleba yNorton\te st20040324 .bak"
set @command = 'C:\Progra~1\WinZip\WINZIP 32.EXE -min -a -en ' + @zipfilename + ' ' + @localfilename
--SELECT @command
exec master..xp_cmdshell @command
This command succeeds at command line, in under 1 second total run-time (file is 409 KB uncompressed):
c:\Progra~1\WinZip\WINZIP3
Yet, when I run the following in Query Analyzer, the process just grinds away and hangs and hangs. I'm at 8 minutes plus, and still "processing".
Everything is on the local machine/drive, a 1 gig mem XP Professional box.
Thanks for all your help. I'm about to put my fist through my machine.
--------------------------
declare @localfilename varchar(255)
declare @zipfilename varchar(255)
declare @command varchar(255)
set nocount on
set @localfilename = '"C:\Documents and Settings\SWatkins\My Documents\1Projects\Ogleba
set @zipfilename = '"c:\OGL_cta_backup.zip"'
--C:\Progra~1\WinZip\WINZI
set @command = 'C:\Progra~1\WinZip\WINZIP
--SELECT @command
exec master..xp_cmdshell @command
ASKER
Ultimately, I had to abandon the xp_cmdshell approach. I went back to adwiseman's approach, which I did not initially understand, but after testing and reviewing the Dynamic Properties Task, I figured it out.
Thanks to dhenson for the time and trouble -- I'm guessing the xp_cmdshell approach works, but I couldn't get it to.
My near-final solution (without the "date in filename" manipulation part) on my local dev machine:
-------------------------- ---
Function Main()
Set task = DTSGlobalVariables.Parent. Tasks("DTS Task_DTSCr eateProces sTask_1"). CustomTask
task.ProcessCommandLine = """C:\Program Files\WinZip\WINZIP32.EXE" " -min -a -en ""c:\OGL_cta_backup.zip"" ""C:\Documents and Settings\SWatkins\My Documents\1Projects\Ogleba yNorton\te st20040324 .bak"" "
Main = DTSTaskExecResult_Success
End Function
-------------------------- ---
Thanks to dhenson for the time and trouble -- I'm guessing the xp_cmdshell approach works, but I couldn't get it to.
My near-final solution (without the "date in filename" manipulation part) on my local dev machine:
--------------------------
Function Main()
Set task = DTSGlobalVariables.Parent.
task.ProcessCommandLine = """C:\Program Files\WinZip\WINZIP32.EXE"
Main = DTSTaskExecResult_Success
End Function
--------------------------
See this link:
https://www.experts-exchange.com/questions/20909916/DTS-SQL-Execute-Task-with-global-variable.html