Page 1 of 1

help with routine needed

Posted: Mon Mar 16, 2009 1:27 pm
by efxuser
I am writing this routine to write job log to a file.The routine was working when tryin to display on screen.when i changed ot rite to a file it is giving me compilation error.Any pointers appreciated.

0027 On Error

^
End of Line unexpected, Was expecting: '!', '=', "AND", "OR", "LT", "LE",
"GT", "GE", "NE", "EQ", "MATCH", "GOSUB", "GOTO"
0037 Call DSLogFatal("Cannot open file ":Filename, "MyRoutine")

^
WARNING: Text found after final END statement






Code: Select all

$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF
 

Ans = 0

FileName =" /home/cvid/joblog.txt"

 hJob = DSAttachJob(JobName, DSJ.ERRNONE)
RealJobName = DSGetJobInfo(hJob, DSJ.JOBNAME)
If RealJobName Matches "'-'1N0N"
Then
   Ans = -1  ;  
End
Else
	OpenSeq FileName To FileVar Then
	   Result = DSGetLogSummary(hJob, DSJ.LOGINFO,  StartTimeStamp, EndTimeStamp, 0)
	   WriteSeq Result to FileName Else
	   On Error
  		Call DSLogWarn("Cannot open file ":FileName, "MyRoutine")
  	   End
  	   End 
	   Call DSLogInfo(Result, "Testingkkkkkkk")
	End Else
	   Call DSLogFatal("Cannot open file ":FileName, "MyRoutine")
	   GoTo ErrorExit
	End

End
 
ErrCode = DSDetachJob(hJob)

RETURN(Ans)

Posted: Mon Mar 16, 2009 2:04 pm
by DSguru2B
Is that your complete routine? I do not see subfunction ErrorExit?

Posted: Mon Mar 16, 2009 2:15 pm
by efxuser
<modified>

Posted: Mon Mar 16, 2009 2:46 pm
by efxuser
my subroutine just assigns return code and logs.
I guess I am messing up the gile closing and end else...i cannot figure it out.
any help is appreciated.

Posted: Mon Mar 16, 2009 3:12 pm
by efxuser
heres my another try

Code: Select all

DEFFUN OpenSequentialFile(filename, openmode, writemode, logevents) CALLING "DSU.OpenSequentialFile"

$IFNDEF JOBCONTROL.H
$INCLUDE DSINCLUDE JOBCONTROL.H
$ENDIF

 Ans = 0

 hJob = DSAttachJob(JobName, DSJ.ERRNONE)
RealJobName = DSGetJobInfo(hJob, DSJ.JOBNAME)
If RealJobName Matches "'-'1N0N"
Then
   Ans = -1  ; * no such job
End
Else
   Result = DSGetLogSummary(hJob, DSJ.LOGINFO, StartTimeStamp, EndTimeStamp, 0)

    Call DSLogInfo(Result, "Testingkkkkkkk")
   TargetFilePath = "/home/cvid/LL.txt"
   fvTargetFile = OpenSequentialFile(TargetFilePath, "W", "O", "Y")
   WriteSeq Result To fvTargetFile 
    Else
       Call DSLogInfo("Can not write to output file." ) 
     
      End 
End

* Detach job, ignoring errors.
ErrCode = DSDetachJob(hJob)

RETURN(Ans)
but no avail.no compiling errors but the file is not getting written to.any clues?

Posted: Mon Mar 16, 2009 3:25 pm
by ray.wurlod
You should have had compile error. DSLogInfo() within the WriteSeq statement requires two arguments. You supply only one. Also, you do not check (using FileInfo()) that the call to OpenSequentialFile() succeeds.

Posted: Mon Mar 16, 2009 3:27 pm
by DSguru2B
First of all, in your original post your are opening the file to the pointer 'FileVar' but when you write your result you are not writing it to that pointer.
Second, your result will be a dynamic array and if you just write it out to a file, it will be all jumbled together, you need to parse the info out. Read about DSGetLogSummary() in help.

What are you trying to accomplish here? Maybe we can direct you to an easier solution.

Posted: Tue Mar 17, 2009 6:41 am
by efxuser
I am trying to create a routine which will take arguments as job name, start timestamp,end timestamp and will write the log to a file whose name will be jobname_starttimestamp_endtimestamp.
Thanks for your time and guidance.

Posted: Tue Mar 17, 2009 7:40 am
by DSguru2B
Ok, lets take a step back, you are writing a basic routine in a parallel job. Are you writing a before/after job subroutine, yes?
Input your parameters with a delimiter say pipe(|).
Inside the routine, use the field() function to split the argument.
Then create the file using the arguments. Read about the different functiaonlities of DSGetLogInfo(). Identify the correct one you want to use.
Then first get the file creating and log production part working. Then we can work onto the last piece to populate the file with the log, 'properly' portion.

Posted: Tue Mar 17, 2009 7:52 am
by efxuser
No, Iam looking to create a routine which I will be calling in the end of a sequence. So in that case the server routine can take multiple parameters correct?

Posted: Tue Mar 17, 2009 8:19 am
by DSguru2B
Sounds reasonable. Before you actually sit down to code, go through the basic guide and read about
1)How to create a file
2) How to write to a file
3)Different DSGetLogInfo() functions.
This will help you cut down your development time.