Basic program to monitor path
Moderators: chulett, rschirm, roy
followup
Is it fine to do this in job control?
UnixCmd="sd.dfd.com" (hostname)
CALL DSExecute("UNIX", 'sh -x /home/A/B/script.sh', ScreenOutput, ReturnCode)
I ran it and got the same warning "cannot open file" like the previous case.
UnixCmd="sd.dfd.com" (hostname)
CALL DSExecute("UNIX", 'sh -x /home/A/B/script.sh', ScreenOutput, ReturnCode)
I ran it and got the same warning "cannot open file" like the previous case.
Datastage is pretty interesting
Your problem isn't with how you are calling the script but the script itself, I would bet. Make sure you are using absolute paths in your script or are cd'ing to the appropriate directory before attempting to work with any files. Make no assumptions about anything in your script - environment variables, location - anything.
Biggest 'problem' people have is with the fact that the 'current working directory' for a script executed by a DataStage job is the project the job is running from.
Biggest 'problem' people have is with the fact that the 'current working directory' for a script executed by a DataStage job is the project the job is running from.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Make sure the fully qualified paths are been used in the shell. Also check if any Environmental variable been used, which is not avialable from datastgage.
If no, paste the exact script been used and exact error message that appear in Director. That will be usefull to indentify the fact.
If no, paste the exact script been used and exact error message that appear in Director. That will be usefull to indentify the fact.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
DSExecute has four arguments, the second being the command to execute. If you look at the original post I made, I constructed the unix command first in a variable and then used the variable as th second argument.
Your usage is not correct. The UnixCmd line you posted is irrelevant if you are constructing the statement in the CALL DSExecute anyway.
I suggest you post the actual logic, and the actual error messages because a lot of the time the errors are lost when you translate for posting.
To debug what you're doing, try:
Make sure the script can be "seen" given that permissions may be an issue. You could also have the wrong path. I doubt /home/A/B is correct, you've obviously changed something.
My guess is you have an incorrect path.
Your usage is not correct. The UnixCmd line you posted is irrelevant if you are constructing the statement in the CALL DSExecute anyway.
I suggest you post the actual logic, and the actual error messages because a lot of the time the errors are lost when you translate for posting.
To debug what you're doing, try:
Code: Select all
UnixCmd = 'ls -l /home/A/B/script.sh'
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")
My guess is you have an incorrect path.
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
The path /home/A/B/script.sh is the path to the script on the unix server. Apparently the default DS path is not this, so I need to set it. Could someone tell me how to change the path please?
Thanks
Julia
Thanks
Julia
Datastage is pretty interesting
You don't need to "change the path". Your script needs some tweakage to use absolute paths I would bet. Easiest way to resolve this is to post your script, wrapped in 'code' tags to preserve formatting. Then we can make more specific 'suggestions' for changes. ![Wink :wink:](./images/smilies/icon_wink.gif)
![Wink :wink:](./images/smilies/icon_wink.gif)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
folowup
Heres the script
Code: Select all
#!/bin/ksh
while read AGE V_PATH DELAY
do
cd $V_PATH
for file in $(ls)
do
if [[ $(( $($HOME/./fileage $file)/60)) -ge $AGE ]]
then
echo $file >>outputfiles.txt
fi
done >outputfiles.txt
final=`wc -l outputfiles.txt|awk '{print $1}'`
if [ $final -ge 1 ]
then
echo $final "Unprocessed files in" $V_PATH|mailx -s "Unprocessed Files. Please Check!" you@me.com
else
echo "Everything's OK"
fi
rm -f outputfiles.txt
sleep $DELAY
cd -
done < filepathinput.txt
Datastage is pretty interesting
Please stop talking about path. The terminology is "working directory", or PWD. When a DataStage job executes a shell command, the PWD is the project. You can verify this by using the Unix command "pwd". If the DataStage job were to execute this in DSExecute, you should see the fully qualified path to your project.
In any shell scripting, you MUST exercise some sort of discipline when dealing with directory paths. Either always fully qualify every command and file name, or make your script change its current working directory using the cd command to place the executing environment in the appropriate location if you're going to use "relative" notation. Since your script is written assuming that it is running in a certain location, your best option is to just add a cd statement at the beginning of the script and make sure it's correct.
In any shell scripting, you MUST exercise some sort of discipline when dealing with directory paths. Either always fully qualify every command and file name, or make your script change its current working directory using the cd command to place the executing environment in the appropriate location if you're going to use "relative" notation. Since your script is written assuming that it is running in a certain location, your best option is to just add a cd statement at the beginning of the script and make sure it's correct.
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