Dscmdexport via Task Scheduler
Moderators: chulett, rschirm, roy
Dscmdexport via Task Scheduler
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
@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
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
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
and let us know the results and anything in that log files if created.
Do something like
Code: Select all
........%\%%a.dsx /V > %ExportDir%\%%a.log
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.![Wink :wink:](./images/smilies/icon_wink.gif)
Genius may have its limitations, but stupidity is not thus handicapped.
![Wink :wink:](./images/smilies/icon_wink.gif)
Thanks for the reply. I updated my script to include the log file output, but the log file is 0k (blank).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 likeand let us know the results and anything in that log files if created.Code: Select all
........%\%%a.dsx /V > %ExportDir%\%%a.log
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
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.
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.
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.![Wink :wink:](./images/smilies/icon_wink.gif)
Genius may have its limitations, but stupidity is not thus handicapped.
![Wink :wink:](./images/smilies/icon_wink.gif)
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 :wink:](./images/smilies/icon_wink.gif)
![Wink :wink:](./images/smilies/icon_wink.gif)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
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.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.
Last edited by brownnt on Tue Feb 02, 2010 9:24 am, edited 1 time in total.
Kim is using 7.5 where I am on 8.01. Kim also uses dsexport where I am using dscmdexport.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.
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
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.
:: -----------------------------------------------------------------
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.
:: -----------------------------------------------------------------
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.![Wink :wink:](./images/smilies/icon_wink.gif)
Genius may have its limitations, but stupidity is not thus handicapped.
![Wink :wink:](./images/smilies/icon_wink.gif)
-
- Premium Member
- Posts: 1044
- Joined: Wed Sep 29, 2004 3:30 am
- Location: Nottingham, UK
- Contact:
Re: Dscmdexport via Task Scheduler
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.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.
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?
Phil Hibbs | Capgemini
Technical Consultant
Technical Consultant
Re: Dscmdexport via Task Scheduler
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.PhilHibbs wrote: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.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.
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?
-
- Premium Member
- Posts: 1044
- Joined: Wed Sep 29, 2004 3:30 am
- Location: Nottingham, UK
- Contact:
Re: Dscmdexport via Task Scheduler
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?brownnt wrote:Yes, I need start so I can wait for each project to finish exporting before the next one starts.
Phil Hibbs | Capgemini
Technical Consultant
Technical Consultant
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
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.
As PhilHibbs mentioned try to run it without start/wait.
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.![Wink :wink:](./images/smilies/icon_wink.gif)
Genius may have its limitations, but stupidity is not thus handicapped.
![Wink :wink:](./images/smilies/icon_wink.gif)
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.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.
Thanks,