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.
output job names from a .dsx file
Moderators: chulett, rschirm, roy
Re: output job names from a .dsx file
you can try thisBill_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.
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.
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