Page 1 of 2

Dscmdexport via Task Scheduler

Posted: Tue Feb 02, 2010 7:28 am
by brownnt
I am working on a batch file that runs dscmdexport to export a list of my projects from reading a text file of project names. This batch file works when I run it interactively, but the dscmdexport command does not export the projects when I run it via the windows task scheduler. Anyone have any suggestions. Below is my script:

@ECHO OFF
ECHO ***********************************************************************
ECHO * This batch script is used to Export all the projects to the E:\DS_Exports
ECHO * folder. This must be run from a DataStage client machine. The
ECHO * Projects.txt file gets auto generated by the dsjob list command.
ECHO ***********************************************************************
REM CHANGES:
REM 02/01/2010 CREATED

ECHO ***********************************************************************
ECHO * SET VARIABLES...
ECHO ***********************************************************************
SET Host=MyHostName
SET User=User
SET Password=Password
SET ExeDir=E:\IBM\InformationServer\Clients\Classic
SET ExportDir=E:\DS_Exports

ECHO ***********************************************************************
ECHO * CREATE PROJECTS.TXT FILE...
ECHO ***********************************************************************
%ExeDir%\dsjob -lprojects > %ExportDir%\Projects.txt
Sleep 5

ECHO ***********************************************************************
ECHO * START EXPORT...
ECHO ***********************************************************************
for /f "tokens=* delims=" %%a in (%ExportDir%\Projects.txt) do (start /wait %ExeDir%\dscmdexport /H=%Host% /U=%User% /P=%Password% %%a %ExportDir%\%%a.dsx /V)
EXIT

Posted: Tue Feb 02, 2010 8:33 am
by priyadarshikunal
You are running the script in verbose mode so why don't you put the logs in to a log file to make the life a bit easy. Some useful information can be found in the log file.
Do something like

Code: Select all

........%\%%a.dsx /V > %ExportDir%\%%a.log
and let us know the results and anything in that log files if created.

Posted: Tue Feb 02, 2010 8:55 am
by brownnt
priyadarshikunal wrote:You are running the script in verbose mode so why don't you put the logs in to a log file to make the life a bit easy. Some useful information can be found in the log file.
Do something like

Code: Select all

........%\%%a.dsx /V > %ExportDir%\%%a.log
and let us know the results and anything in that log files if created.
Thanks for the reply. I updated my script to include the log file output, but the log file is 0k (blank).

Posted: Tue Feb 02, 2010 9:09 am
by priyadarshikunal
try to echo path and the command you are going to execute.

like adding

echo %PATH% >path.txt
echo (start /wait %ExeDir%\dscmdexport /H=%Host% /U=%User% /P=%Password% %%a %ExportDir%\%%a.dsx /V) > command.txt

to see if path is correctly reflected to the script and you are getting the correct values in for parameters.

also try to run the command from E:\IBM\InformationServer\Clients\Classic directory by using

cd %ExeDir% before command execution.

Posted: Tue Feb 02, 2010 9:10 am
by chulett
There's a complete, working version of one in the DS Tips section of Kim Duke's website. You could use or at least crib from it. :wink:

Posted: Tue Feb 02, 2010 9:22 am
by brownnt
priyadarshikunal wrote:try to echo path and the command you are going to execute.

like adding

echo %PATH% >path.txt
echo (start /wait %ExeDir%\dscmdexport /H=%Host% /U=%User% /P=%Password% %%a %ExportDir%\%%a.dsx /V) > command.txt

to see if path is correctly reflected to the script and you are getting the correct values in for parameters.

also try to run the command from E:\IBM\InformationServer\Clients\Classic directory by using

cd %ExeDir% before command execution.
When I echo the command it does give me the correct path and values both when I run this interactively or by task scheduler. This works great when I run the bat file interactively via start -> run, just not as a scheduler task.

Posted: Tue Feb 02, 2010 9:23 am
by brownnt
chulett wrote:There's a complete, working version of one in the DS Tips section of Kim Duke's website. You could use or at least crib from it. :wink:
Kim is using 7.5 where I am on 8.01. Kim also uses dsexport where I am using dscmdexport.

Posted: Tue Feb 02, 2010 9:28 am
by priyadarshikunal
As Craig noted, you can get the script from below url

http://www.duke-consulting.com/DataStage_Tips.htm

The script has a a lot of notes/hints to debug your script. something like

:: -----------------------------------------------------------------
:: Required Components:
:: dsjob.exe (Windows Version)
:: (also requires vmdsapi.dll)
:: Advised to place both files under Windows System directory.
:: -----------------------------------------------------------------

Re: Dscmdexport via Task Scheduler

Posted: Tue Feb 02, 2010 10:04 am
by PhilHibbs
brownnt wrote:This batch file works when I run it interactively, but the dscmdexport command does not export the projects when I run it via the windows task scheduler. Anyone have any suggestions.
The only thing I can think of is there is something different about the environment when the scheduler runs the script. I see from other replies that you've already checked the path.

Try writing the whole "start /wait %ExeDir%\dscmdexport /H=%Host% /U=%User% /P=%Password% %%a %ExportDir%\%%a.dsx /V" as text to a file, in case there's something odd in there.

*Update*: I see priyadarshikunal already suggested exactly that. Sorry.

Maybe Windows isn't letting you spawn a start command? Do you need the start, can't you just invoke dscmdexport directly?

Re: Dscmdexport via Task Scheduler

Posted: Tue Feb 02, 2010 10:06 am
by brownnt
PhilHibbs wrote:
brownnt wrote:This batch file works when I run it interactively, but the dscmdexport command does not export the projects when I run it via the windows task scheduler. Anyone have any suggestions.
The only thing I can think of is there is something different about the environment when the scheduler runs the script. I see from other replies that you've already checked the path.

Try writing the whole "start /wait %ExeDir%\dscmdexport /H=%Host% /U=%User% /P=%Password% %%a %ExportDir%\%%a.dsx /V" as text to a file, in case there's something odd in there.

Maybe Windows isn't letting you spawn a start command? Do you need the start, can't you just invoke dscmdexport directly?
Yes, I need start so I can wait for each project to finish exporting before the next one starts. I agree, I know it's something with task scheduler and the start command, but not sure what.

Re: Dscmdexport via Task Scheduler

Posted: Tue Feb 02, 2010 10:29 am
by PhilHibbs
brownnt wrote:Yes, I need start so I can wait for each project to finish exporting before the next one starts.
I'm not convinced that you do. dscmdexport is a command line program, so it should just run in the same process as the batch file and return. Unless dscmdexport is actually a batch file on your system that points to the real dscmdexport.exe, I do that sometimes, in which case you need "call" instead of "start /wait". Is the start command a hang-over from a previous attempt at using dsexport, which is a GUI app that would run in its own process?

Posted: Tue Feb 02, 2010 10:45 am
by priyadarshikunal
dscmdexport.exe will not release the process unless it completes/fails. Hence you don't need to specify that. That the next thing I will try to get rid of.

As PhilHibbs mentioned try to run it without start/wait.

Posted: Tue Feb 02, 2010 2:43 pm
by brownnt
After removing the start /wait atleast now the scheduled task will run and create log files with the error below in the logfiles.

dscmdexport aborted:
Failed to attach to the project


Thanks.

Posted: Tue Feb 02, 2010 2:47 pm
by chulett
Probably a crendentials issue. For the 8.x release, I believe you'll need to add the /D "domain" parameter as well as the normal userid/password.

Posted: Tue Feb 02, 2010 2:56 pm
by brownnt
chulett wrote:Probably a crendentials issue. For the 8.x release, I believe you'll need to add the /D "domain" parameter as well as the normal userid/password.
Any idea on how to setup the Task Scheduler service login? Right now it is configured to run as Local System, the task itself uses a DOMAIN\DataStageAdmin account to run, but my script has a local DataStage account in the /U=Username command line syntax.

Thanks,