Basic program to monitor path
Moderators: chulett, rschirm, roy
Basic program to monitor path
Hi,
I want a DS basic job to monitor a path on a unix server and sends a mail if files there are longer than 2hours. Could someone tell me if theres a similar job here please, or give me some idea about this. I am completely new to basic programming. I could do this easily in shell or C.
Thanks
Julia
I want a DS basic job to monitor a path on a unix server and sends a mail if files there are longer than 2hours. Could someone tell me if theres a similar job here please, or give me some idea about this. I am completely new to basic programming. I could do this easily in shell or C.
Thanks
Julia
Datastage is pretty interesting
So, write a shell script and call it from a DS Sequence job command stage or write a Batch job to loop and use CALL DSExecute to periodically run the same shell script.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Using DS Director, from menu Tools --> Batches --> New. In the blank job control canvas, type in this:
UnixCmd="hostname"
CALL DSExecute("UNIX", UnixCmd, ScreenOutput, ReturnCode)
CALL DSLogInfo("The UnixCmd shows this to the screen -->":ScreenOutput, "Test")
CALL DSLogInfo("The UnixCmd had this exit value -->":ReturnCode, "Test")
All DS APIs are documented in your DS BASIC manual available under your Start button, Ascential, Online Documentation. You can write anything you need to do. Consider putting this logic into a loop with a sleep statement to periodically execute your script. Consider exiting the loop (and thus the job) at a predetermined time or exit condition (maybe check for an exit file in a certain directory).
UnixCmd="hostname"
CALL DSExecute("UNIX", UnixCmd, ScreenOutput, ReturnCode)
CALL DSLogInfo("The UnixCmd shows this to the screen -->":ScreenOutput, "Test")
CALL DSLogInfo("The UnixCmd had this exit value -->":ReturnCode, "Test")
All DS APIs are documented in your DS BASIC manual available under your Start button, Ascential, Online Documentation. You can write anything you need to do. Consider putting this logic into a loop with a sleep statement to periodically execute your script. Consider exiting the loop (and thus the job) at a predetermined time or exit condition (maybe check for an exit file in a certain directory).
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
followup
Hi Kenny,
Do I really need to write a loop statement again? I already wrote a working script that does the job. Wouldnt it be enough just to execute the script in DS? I also included a delay in the unix script.
Please advise
Julia
Do I really need to write a loop statement again? I already wrote a working script that does the job. Wouldnt it be enough just to execute the script in DS? I also included a delay in the unix script.
Please advise
Julia
Datastage is pretty interesting
Do whatever you want. Once a job calls a script there's no way to stop the job (without a kill) until the script exits. If your script does the checks and returns a status value, then your job could do the loop. Either Batch or Sequence has the ability to loop.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
DSJOB RUN status code
In your script you need to check the return status...say I generally use a DSJOB -RUN to run the Datastage sequencers from Unix...r.julia wrote:Hi Kenny,
Do I really need to write a loop statement again? I already wrote a working script that does the job. Wouldnt it be enough just to execute the script in DS? I also included a delay in the unix script.
Please advise
Julia
here we check for the return status..there are lot of scripts available..one I saw by kcbland...I took help from him once to create a script which also I had posted here
In general the return from the DSJOB -RUN are
Ready to run- Job Status
# 1 "Finished"
# 2 "Finished with Warning (see log)"
# 9 "Has been reset"
# 11 "Validated OK"
# 12 "Validated (see log)"
# 21 "Has been reset"
# 99 "Compiled"
Wait -Job Status
# 0 "Running"
Failure- Job Status (reset job)
# 3 "Aborted"
# 8 "Failed validation"
# 13 "Failed validation"
# 96 "Aborted"
Track them in your script and then have a decision based loop
# 97 "Stopped"
# 98 "Not Compiled"
Avishek Mukherjee
Data Integration Architect
Chicago, IL, USA.
Data Integration Architect
Chicago, IL, USA.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Create a job sequence.
In that job sequence use an Execute Command activity to run your script.
Follow it with a Routine activity that invokes UtilityWarningToLog (or UtilityInfoToLog) to log any message, and a Notification activity to send email.
Between the Execute Command activity and the next activity specify a custom trigger based either on the shell script's exit status or it's output.
If you have DataStage version 7.5 you can enclose all of the above in a loop between a StartLoop and an EndLoop activity. In this case you will need a second path (where no email needs to be sent) emanating from the Execute Command activity, and join both streams using a Sequencer prior to the EndLoop activity. You would also need to determine a mechanism for advising the loop to exit, such as a file coming into existence.
In that job sequence use an Execute Command activity to run your script.
Follow it with a Routine activity that invokes UtilityWarningToLog (or UtilityInfoToLog) to log any message, and a Notification activity to send email.
Between the Execute Command activity and the next activity specify a custom trigger based either on the shell script's exit status or it's output.
If you have DataStage version 7.5 you can enclose all of the above in a loop between a StartLoop and an EndLoop activity. In this case you will need a second path (where no email needs to be sent) emanating from the Execute Command activity, and join both streams using a Sequencer prior to the EndLoop activity. You would also need to determine a mechanism for advising the loop to exit, such as a file coming into existence.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
"Doesn't work" in what sense? What does the job's log say when the command is execute?
Not sure what you are asking about the parameters. There is a specific 'box' for them as well, put any you need there. It will combine the two before the command is executed.
Not sure what you are asking about the parameters. There is a specific 'box' for them as well, put any you need there. It will combine the two before the command is executed.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
followup
The Execute Command applet has two inputs COMMAND and PARAMETERS. In the command, I put the path where the script is located ( /home/A/B/script.sh - I put sth like this). In the parameter box, I didnt put anything.
But the script did not execute.
I also tried this option:
UnixCmd="sd.dfd.com" (hostname)
CALL DSExecute("UNIX", 'sh -x /home/A/B/script.sh', ScreenOutput, ReturnCode)
CALL DSLogInfo("The UnixCmd shows this to the screen -->":ScreenOutput, "Test")
CALL DSLogInfo("The UnixCmd had this exit value -->":ReturnCode, "Test")
I tried to execute this first to see if it works, before proceeding with the loop statement.
Thanks
Julia
But the script did not execute.
I also tried this option:
UnixCmd="sd.dfd.com" (hostname)
CALL DSExecute("UNIX", 'sh -x /home/A/B/script.sh', ScreenOutput, ReturnCode)
CALL DSLogInfo("The UnixCmd shows this to the screen -->":ScreenOutput, "Test")
CALL DSLogInfo("The UnixCmd had this exit value -->":ReturnCode, "Test")
I tried to execute this first to see if it works, before proceeding with the loop statement.
Thanks
Julia
Datastage is pretty interesting
folowup
THe script reads from an input file. When I execute it normally it works, but when I execute from DS, it says cannot open file in the log. I checked the rights and everything looks ok.
Thanks
Julia
Thanks
Julia
Datastage is pretty interesting