Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Weird Script

Status
Not open for further replies.

jmanj

Programmer
May 20, 2003
298
US
I have a ksh scripts that when called by a cobol program
although it is successful I'm getting the following
log messages 4 times.

sh: D: not found.

This script is in aix and when I call the script using the
command line I'm not getting any messages at all.

The script is just a copy from other working scripts and this
is the only one I'm having such messages so far.

Thanks for any input.
 
Its interesting that you are calling them 'ksh' scripts, however the error message is being reported from 'sh', i.e. the Bourne shell, not Korn.

Perhaps the scripts are missing the #!/usr/bin/ksh shebang line at the beginning? Or perhaps COBOL is running them specifically using /usr/bin/sh? Try running them yourself using sh and see if the same error comes up, i.e. /usr/bin/sh scriptname.

Annihilannic.
 
Thanks for the information. All of our scripts are in korn shell and thus contains #!/usr/bin/ksh. I have not recompiled those other cobol programs that has calls to scripts. This is the only one program thats doing it so far.

I realized that there was an OS upgrade done to our aix system recently and I wonder if there was something that changed between our OS and micro focus cobol.

I have stripped the called script of everything except a single line that echoes "TEET TEST" and still having that weird log message. Again there is no message when called from the command line.

jmanj
 
Please post your ksh script if you can. It could shed some light on the problem.

Also, post the COBOL lines that call it if you can.
 
Yes indeed ! Here it is. Thanks.

From Cobol working storage:

******************************************************************
01 Z6014-SCRIPT.
02 Z6014WS-CMD-STRING.
03 Z6014WS-SYS-COMMAND PIC X(100) VALUE SPACES.
03 Z6014WS-NULL-CHAR PIC X(001) VALUE x"00".

From the procedure division:

**** call EMAIL script.

INITIALIZE Z6014WS-CMD-STRING.

STRING "Z6014_mail2.ksh"
DELIMITED BY SIZE
INTO Z6014WS-CMD-STRING.

CALL "SYSTEM" USING Z6014WS-CMD-STRING.

Here's the simple stripped down khs script.

#!/bin/ksh
#
###############################################################################
## ##
## Z6014_mail.ksh ##
## ##
## This script called by Z6014 cobol pgm to send email msg to users ##
## ##
###############################################################################
## SET ENVIRONMENT VARIABLES AND START LAWSON IN SINGLE USER MODE ##
###############################################################################
##$HOME/.profile
##. $LAWDIR/system/profile
##umask 0
##
###############################################################################
## OBTAIN PRODUCT LINES FOR CURRENT ENVIRONMENT ##
###############################################################################
## set up the environment

echo "test test test"

#rm $TMPDIR/$TMPFILE1
#rm $TMPDIR/$TMPFILE3


Thanks for any help.
 
I have changed the program call to "Z6014_mail2.sh"
copied Z6014_mail2.ksh into Z6014_mail2.sh, change
#!/bin/ksh into #!/bin/sh and still getting the same result.

 
would debugging teh script help

below your #!/bin/ksh line, add the following line:
Code:
set -x
This will turn on debugging.

Hope somebody here will be able to help if you post the output of that..
 
I turned on debugging flag and here's the result

+ echo test test test
test test test
sh: D: not found.
sh: D: not found.
sh: D: not found.
sh: D: not found.

Thanks.
 
Well, you'll need to show more of the script... What lines except comments follow after the [tt]echo "test test test"[/tt]?


HTH,

p5wizard
 
Replace this:
INITIALIZE Z6014WS-CMD-STRING.

STRING "Z6014_mail2.ksh"
DELIMITED BY SIZE
INTO Z6014WS-CMD-STRING.
with this:
MOVE "Z6014_mail2.ksh"
TO Z6014WS-CMD-STRING.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV,

Thanks for your suggestion but it have the same result.

p5wizard,


Please the script above. That's the entire contents of the script. I checked the script file if there are some weird
hidden characters but could not find anything wrong.

Thanks for all your help.

jmanj
 
OK,

this means one of the following is true:

1) your COBOL program is calling some more command lines using the [tt]CALL "SYSTEM"[/tt] construct. Read through the whole of the COBOL program. Put in a [tt]DISPLAY "After calling mail script.".[/tt] line or similar in your COBOL program.

2) your COBOL program is calling a different version of your script than you think it is calling. Put in another echo "test2" in the script and see if you notice anything. Move the full pathname of the script you want to run to the [tt]Z6014WS-CMD-STRING[/tt] variable. Perhaps a bigger PIC X(255) is then necessary?

3) somehow the variable [tt]Z6014WS-CMD-STRING[/tt] isn't properly initialized and more than you want is being processed by the shell. Put in a line [tt]DISPLAY Z6014WS-CMD-STRING.[/tt] right before the [tt]CALL "SYSTEM"[/tt] line.

Perhaps there are even more possible causes. More debugging will be necessary...


HTH,

p5wizard
 
p5wizard,

Followed your instruction and still have the same result.

here's the content of the script:

#!/usr/bin/sh
set -x
#
###############################################################################
## ##
## Z6014_mail.ksh ##
## ##
## This script called by Z6014 cobol pgm to send email msg to users ##
## 02/14/2008 mlj ##
###############################################################################
## SET ENVIRONMENT VARIABLES AND START LAWSON IN SINGLE USER MODE ##
###############################################################################
##$HOME/.profile
##. $LAWDIR/system/profile
##umask 0
##
###############################################################################
## OBTAIN PRODUCT LINES FOR CURRENT ENVIRONMENT ##
###############################################################################
## set up the environment

echo "test2 test2 test2"



Here's the cobol statements:

INITIALIZE Z6014WS-CMD-STRING.

STRING "Z6014_mail2.ksh"
DELIMITED BY SIZE
INTO Z6014WS-CMD-STRING.

DISPLAY "Calling Script".
DISPLAY Z6014WS-CMD-STRING.

CALL "SYSTEM" USING Z6014WS-CMD-STRING.

DISPLAY "Pgm-end".

STOP-RUN.

And here's the result:


Calling Script
Z6014_mail2.ksh
+ echo test2 test2 test2
test2 test2 test2
sh: D: not found.
sh: D: not found.
sh: D: not found.
sh: D: not found.
Pgm-end


as you can see the these messages comes after the call
to the script and before the last DISPLAY statement.

Thanks.
 
Slowly running out of ideas here... ;-)

Try this. In the script: modify the line
[tt]echo "test2 test2 test2"[/tt]
into
[tt]echo "test2 test2 test2"[red]; exit 0[/red][/tt]

get back to us with the result.

HTH,

p5wizard
 
Okay here's the result. Thanks.

Calling Script
Z6014_mail2.ksh
+ echo test2 test2 test2
test2 test2 test2
+ exit 0
sh: D: not found.
sh: D: not found.
sh: D: not found.
sh: D: not found.
Pgm-end
 
Well, wherever that [tt]sh: D: not found.[/tt] comes from, it sure isn't from somewhere within the Z6014_mail2.ksh script...

HTH,

p5wizard
 
How about using MOVE ZEROES instead of INITIALIZE to initialise the string?

Annihilannic.
 
The string is a 100 character length and not numeric. the
101ist character is a null character.

Please note that this is our standard initialization routine that is present in a lot of our cobol programs. So far I could only do this is test environment and still awaiting for the users to call some of this cobol programs with script routine.

This is the first program and script created/compiled since the last OS upgrade. I really need some answer to this puzzle before I confront the AIX admin. My suspect is that something has happened between micro focus cobol and the OS upgrade. Obviously this has nothing to do with calling the script. The scripts runs perfectly well. As I mentioned before, the script is okay when called from the command line. My suspect is maybe there is a symbolic link to both the bourne shell and korn shell that needs tweaking.

Thanks all.

jmanj
 
OK. Just for troubleshooting purposes, can you put a pause in the script and run a Process Status command while your script is running? Maybe you can see something odd in the way the script is being called from the COBOL app.



"Proof that there is intelligent life in Oregon. Well, Life anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top