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!

Writing to a directory/file specified by pipe 1

Status
Not open for further replies.

SiouxCityElvis

Programmer
Jun 6, 2003
228
US
How do I take a hard coded directory from working storage and concatenate the name of a file on that directory in order to use it in my SELECT statement for specifying where and what file to write my data to?

I keep getting a COBOL I/O error 30, UNIX Error 13 on my OPEN file statement:/home/fname/lname/results/TEST.txt

Here's the pieces of code involved:

SELECT FILE-RECORD ASSIGN TO OUTPUT, FILE-NAME
ORGANIZATION IS LINE SEQUENTIAL.

FD OUT-FILE-RECORD.
01 OUT-FILE-REC.
03 FILE-NAME PIC X(40)
.....
.....

Then, I have a WS variable with hardcoded value for specifying directory:
WS-DIR PIC X(32) VALUE "/home/fname/lname/results/".
WS-TEMP-FILE PIC X(8).
Later, in Procedure, I UNSTRING the Pipe rec value into my OUT-FILE-RECORD variables.
UNSTRING PIPE-REC DELIMITED BY "^"
INTO
WS-TEMP-FILE
FILE-FNAME
etc...
...
END-UNSTRING.
STRING WS-DIR DELIMITED BY SIZE
WS-TEMP-FILE DELIMITED BY SIZE
INTO WS-RFMT-FILE-NAME
END-STRING.
MOVE WS-RFMT-FILE-NAME TO FILE-NAME.

But, I get the error indicated above when I do the
OPEN OUTPUT OUT-FILE-RECORD statement.
This makes no since to me as the error indicates:
/home/fname/lname/results/TEST.txt

so, obviously, the concatenation is happening, but for some reason, it does not like to OPEN(create) that file with that path. The path is valid/exists, but it won't create the file.

Please help if you have any suggestions.
Thanks.
-David
 
David,

A couple possibilities:

1. You are not initializing WS-RFMT-FILE-NAME. STRING does not change anything beyond the actual characters that are moved into the receiving item (i.e. does not space fill).

2. WS-DIR is PIC X(32) but the initial value contains only 26 characters.
Add to this the fact that you are doing a STRING ... DELIMITED BY SIZE, and you end up with embedded spaces in the value of WS-RFMT-FILE-NAME. My guess is that your AIX file system does not have a corresponding pathname (with embedded spaces considered).

Try:
Code:
MOVE SPACES TO WS-RFMT-FILE-NAME
STRING WS-DIR DELIMITED BY SPACE
       WS-TEMP-FILE DELIMITED BY SPACE
  INTO WS-RFMT-FILE-NAME
END-STRING.


Tom Morrison
 
I tried this. I was already moving spaces to the WS-RFMT-FILE-NAME field, but I did go ahead and change the STRING to be delimiting the fields by SPACE instead of SIZE. But, dog-gawnit, I'm still getting the same COBOL error.

We are running on our LINUX platform now also.
 
Tom,

The directory is an absolute path of where I will be placing the file.
The directory: /home/fname/lname/results already exists.
Notice, I am putting
/home/fname/lname/results/ and appending the file name so that it will be a value of
/home/fname/lname/results/filename
 
Well, on Linux, error 13 is a....
Code:
#define EACCES          13      /* Permission denied */

What this means is that the user under which your COBOL program is running does not have permission to create a file in the directory you are specifying (including, perhaps, not having permission to search some intermediate directory on the path).

Tom Morrison
 
I'll bet you've got the answer there. Which makes sense as we have just recently set up our Linux and the Java programmer is the one that created that directory for his own testing purposes. Looks like we need the chmod that to 777 to allow permissions for not only he as the owner but myself as well so that I can create files in his directory.

Thanks a bunch. Star to ya.
-David
 
BTW,

I'm looking around in my Linux for a list of errors.

Where did you find that error 13 was "Permission denied"?

Thanks.
-David
 
hmmm. Didn't get anything from that.
I typed in

"find /usr -name errno.c -print" and it just returned down a line at a command prompt again.
When I tried "david" in place of "-name" I received a message stating:
"find: invalid predicate '-dbasile'"
 
it should be
find / -name errno.h - print
(Note the ".h", not ".c", as this is an include file.

It is normally in the include/sys folder (/usr/lib/include/sys) but DO search for it
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top