output job names from a .dsx file

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Bill_G
Premium Member
Premium Member
Posts: 74
Joined: Thu Oct 20, 2005 9:34 am

output job names from a .dsx file

Post by Bill_G »

I have several .dsx files that I inherited from an inept developer that are not named properly and no map to the contents has been provided.

I would like to see just the job names. Does anyone have a utility that will parse out the job names from a .dsx file?

I would rather not create a new project and import.
JFR
Participant
Posts: 3
Joined: Wed Oct 20, 2010 7:02 pm
Location: Northern California

Re: output job names from a .dsx file

Post by JFR »

Bill_G wrote:I have several .dsx files that I inherited from an inept developer that are not named properly and no map to the contents has been provided.

I would like to see just the job names. Does anyone have a utility that will parse out the job names from a .dsx file?

I would rather not create a new project and import.
you can try this
awk ' $0 ~ "BEGIN DSJOB" {getline ; print $0}' < file.dsx

note : I didn't dig enough to see if DSJOB would cover shared containers, routines, etc...

Note: if you try to import the dsx in a project using the option to select them 1 by 1, you can compare with the output of the awk.

Regards.
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

Rather crude but here it is.

Code: Select all

'-------------------------------------------------------------------------------
'
' File:            GetJobList.vbs
' Created:         October 16, 2010
' Last Modified:   October 16, 2010
' Version:         1.0
'-------------------------------------------------------------------------------
' Main Function:     
' Create a list of jobs in DataStage dsx file.
'-------------------------------------------------------------------------------
' Usage:  GetJobList.vbs 
'
'-------------------------------------------------------------------------------
' Notes:
'-------------------------------------------------------------------------------

On Error Resume Next

' Kim this works well
'  has folder gui

Const WINDOW_HANDLE = 0
Const BIF_EDITBOX = &H10
Const BIF_NONEWFOLDER = &H0200
Const BIF_RETURNONLYFSDIRS = &H1
Const ForReading = 1, ForWriting = 2, ForAppending = 8 

' iBatchSw = 1 extracts only batch job names
iBatchSw = 0

Set objShell = CreateObject("Shell.Application")
Set wshShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

'**Browse For Folder To Be Processed
strPrompt = "Please select the folder to process."
intOptions = BIF_RETURNONLYFSDIRS + BIF_NONEWFOLDER + BIF_EDITBOX
' strTargetPath = wshShell.SpecialFolders("MyDocuments")
' strTargetPath = wshShell.SpecialFolders("MyDocuments\Desktop\Kim\Projects")
strTargetPath = wshShell.SpecialFolders("My Computer")
' strTargetPath = wshShell.CurrentDirectory 
strFolderPath = Browse4Folder(strPrompt, intOptions, strTargetPath)

Set objNewFile = objFSO.CreateTextFile(strFolderPath & "\JobLists.txt", True)
Set objFolder = objFSO.GetFolder(strFolderPath)
Set objColFiles = objFolder.Files

For Each file In objColFiles
   If Instr(file.Name, ".dsx") > 0 Then
   	objNewFile.WriteLine(file.Name)
   	Call Get1JobList
   	' WScript.Quit
   End If
Next
objNewFile.Close
WScript.Quit

'**Browse4Folder Function
Function Browse4Folder(strPrompt, intOptions, strRoot)
   Dim objFolder, objFolderItem

   On Error Resume Next

   Set objFolder = objShell.BrowseForFolder(0, strPrompt, intOptions, strRoot)
   If (objFolder Is Nothing) Then
      Wscript.Quit
   End If
   Set objFolderItem = objFolder.Self
   Browse4Folder = objFolderItem.Path
   Set objFolderItem = Nothing
   Set objFolder = Nothing
End Function

'-----------------------------------------------------------
' Subroutine Get1JobList
'-----------------------------------------------------------
Sub Get1JobList
   Set objJobListFileHandle = objFSO.OpenTextFile(strFolderPath & "\" & file.Name, ForReading, True)
   Do While Not objJobListFileHandle.AtEndOfStream
      sLine = objJobListFileHandle.ReadLine
      ' objNewFile.WriteLine(sLine)
      If Instr(sLine, "BEGIN DSJOB") > 0 Then
' Identifier "Batch::DRC0Main""
      	sLine = Trim(objJobListFileHandle.ReadLine)
      	' objNewFile.WriteLine("=>" & sLine)
      	iBegChar = Instr(sLine, Chr(34)) + 1
      	If iBegChar > 0 Then
      		sJobName = Mid(sLine, iBegChar, Len(sLine) - iBegChar)
      		If Instr(sJobName, "Batch::") > 0 And iBatchSw = 1 Then
      			objNewFile.WriteLine(sJobName)
      		Else
      			objNewFile.WriteLine(sJobName)
      		End If
      		' objNewFile.WriteLine(sJobName)
      	End If
      End If
   Loop
   objNewFile.WriteLine(" ")
   Set objJobListFileHandle = Nothing
End Sub
Mamu Kim
kduke
Charter Member
Charter Member
Posts: 5227
Joined: Thu May 29, 2003 9:47 am
Location: Dallas, TX
Contact:

Post by kduke »

You point it to the directory where the dsx files are then it creates a JobLists.txt with DsxFileName and all the jobs in that dsx and then the next DsxFileName in that directory and all its job names.

The directory browser I downloaded from some web site. I added the rest.
Mamu Kim
Bill_G
Premium Member
Premium Member
Posts: 74
Joined: Thu Oct 20, 2005 9:34 am

Post by Bill_G »

Thanks! Very Much.
Post Reply