Dscmdexport via Task Scheduler

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

brownnt
Premium Member
Premium Member
Posts: 21
Joined: Tue Feb 03, 2009 6:07 pm

Dscmdexport via Task Scheduler

Post 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
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post 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.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
brownnt
Premium Member
Premium Member
Posts: 21
Joined: Tue Feb 03, 2009 6:07 pm

Post 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).
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post 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.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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:
-craig

"You can never have too many knives" -- Logan Nine Fingers
brownnt
Premium Member
Premium Member
Posts: 21
Joined: Tue Feb 03, 2009 6:07 pm

Post 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.
Last edited by brownnt on Tue Feb 02, 2010 9:24 am, edited 1 time in total.
brownnt
Premium Member
Premium Member
Posts: 21
Joined: Tue Feb 03, 2009 6:07 pm

Post 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.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post 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.
:: -----------------------------------------------------------------
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Re: Dscmdexport via Task Scheduler

Post 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?
Phil Hibbs | Capgemini
Technical Consultant
brownnt
Premium Member
Premium Member
Posts: 21
Joined: Tue Feb 03, 2009 6:07 pm

Re: Dscmdexport via Task Scheduler

Post 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.
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Re: Dscmdexport via Task Scheduler

Post 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?
Phil Hibbs | Capgemini
Technical Consultant
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post 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.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
brownnt
Premium Member
Premium Member
Posts: 21
Joined: Tue Feb 03, 2009 6:07 pm

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
brownnt
Premium Member
Premium Member
Posts: 21
Joined: Tue Feb 03, 2009 6:07 pm

Post 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,
Post Reply