Exec Dos Command

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

Post Reply
Umbix62
Participant
Posts: 79
Joined: Mon Jan 16, 2006 2:47 pm

Exec Dos Command

Post by Umbix62 »

Hi there

I have to exec a Dos command in the before routine as this:

"Echo 2006/03/20 > pippo.dat"

to create a flat file at the end of this job, if it run without errors. In this file I have to insert only one row with the current data, as for example "2006/03/20". How can I do that? I can put the current date in the command, using for example, the DataStage variable @date? I know I can use a parameter contained the current date but I'ld know if there is a direct method to do that without using parameters.

Thank you

Umberto
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Umberto,

I am not sure about what you need to do; you posted the question as a UNIX server one, but are asking about DOS; you stated that you want a "before routine" to do something after the job completes successfully.

If you has a DOS server installation, you can simply execute

Code: Select all

date /t > pippo.dat
as a shell command to put the current system date into a file.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Make sure you enable the 'Only run after successful completion' option. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

A similar approach for UNIX also involves the date command; the picture option is set according to your requirements. For example

Code: Select all

date +"%yyyy-%MM-%dd" > bippo.dat
But, as Arnd noted, we are not sure whether you are asking about UNIX (your job type in post header) or DOS (your post body).
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Umbix62
Participant
Posts: 79
Joined: Mon Jan 16, 2006 2:47 pm

Post by Umbix62 »

ArndW wrote:Umberto,

I am not sure about what you need to do; you posted the question as a UNIX server one, but are asking about DOS; you stated that you want a "before routine" to do something after the job completes successfully.

If you has a DOS server installation, you can simply execute

Code: Select all

date /t > pippo.dat
as a shell command to put the current system date into a file.
Ok, it works. Thank you very much. I did it in a Unix environment with touch command. Now I work in a Windows 2003 Server and I don't know the Dos Command.

Thank you again to everybody

Umberto
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

touch.exe ships with DataStage. It can be found in the Engine folder's bin subdirectory.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Umbix62
Participant
Posts: 79
Joined: Mon Jan 16, 2006 2:47 pm

Post by Umbix62 »

ray.wurlod wrote:touch.exe ships with DataStage. It can be found in the Engine folder's bin subdirectory. ...
This is the command I used in a Unix environment. I can't access this subdirectory. I have decided to use the command suggested "date /t > filename.dat". If I want to write in that flat file the current date and time?

Thank you

Umberto
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Umberto,

just as with date /t you can use the time /t command to get the current time output in dos.
Umbix62
Participant
Posts: 79
Joined: Mon Jan 16, 2006 2:47 pm

Post by Umbix62 »

ArndW wrote:Umberto,

just as with date /t you can use the time /t command to get the current time output in dos. ...
Ok, but if I want write togheter and not only one?
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

You can append one after other.
date /t > filename.dat
time /t >> filename.date
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Try "echo %DATE% %TIME% > filename.dat"
Umbix62
Participant
Posts: 79
Joined: Mon Jan 16, 2006 2:47 pm

Post by Umbix62 »

ArndW wrote:Try "echo %DATE% %TIME% > filename.dat" ...
Ok, it works. Thank you very much

Umberto
Post Reply