Basic program to monitor path

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

r.julia
Participant
Posts: 23
Joined: Tue Jan 24, 2006 8:04 am

followup

Post by r.julia »

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.
Datastage is pretty interesting
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

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.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

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:

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") 
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.
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
r.julia
Participant
Posts: 23
Joined: Tue Jan 24, 2006 8:04 am

followup

Post by r.julia »

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
Datastage is pretty interesting
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

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:
-craig

"You can never have too many knives" -- Logan Nine Fingers
r.julia
Participant
Posts: 23
Joined: Tue Jan 24, 2006 8:04 am

folowup

Post by r.julia »

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
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

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.
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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Pretty much echoes what I said - assume nothing in your script: where you are, what environment variables are available, path settings - nothing.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply