I have a CLP that I'm trying to write a file to IFS. The file needs to have only LF at the end of each line. Not CRLF.
The file needs to look like this:
At the moment the program is producing this:
I need to remove all the quotes and extra spaces.
The program is complicated. If there is an easier way to write the file I'm all ears.
This is the program I have:
ENDPGM
The program creates a file in Qtemp called FTP
The program writes records to the file
Then the program copies the file to the IFS file
When the program runs the variable &Linedata just before the RUNSQL line looks like this:
The file needs to look like this:
Code:
#!/bin/sh printf sq9zp6r1M3xG005
Code:
" ""#!/bin/sh"" " " printf sq9zp6r1M3XG005 "
The program is complicated. If there is an easier way to write the file I'm all ears.
This is the program I have:
Code:
PGM PARM(&USER &SITE &DIR &PWD &IMGCLG &LDIR) DCL &PWD *CHAR 15 DCL &Q *CHAR 1 Value('''') DCL &LineOut *CHAR 88 DCL &Preamble *CHAR STG(*DEFINED) LEN(40) DEFVAR(&LineOut 1) DCL &Linedata *CHAR STG(*DEFINED) LEN(46) DEFVAR(&LineOut 42) DCL VAR(&Bash ) TYPE(*CHAR) LEN(11) VALUE("#!/bin/sh") CRTSRCPF FILE(QTEMP/FTP) RCDLEN(120) MBR(CMD) CHGVAR VAR(&PREAMBLE) VALUE('Insert into QTEMP/FTP + (SRCDTA) values(' || &Q) CHGVAR VAR(&Linedata) VALUE(&BASH *TCAT &Q || ')') RUNSQL SQL(%TRIM(&LineOut)) COMMIT(*NONE) NAMING(*SYS) CHGVAR VAR(&Linedata) VALUE('printf ' || &PWD *TCAT &Q *TCAT ')') RUNSQL SQL(&LineOut) COMMIT(*NONE) NAMING(*SYS) CPYTOIMPF FROMFILE(QTEMP/FTP) + TOSTMF('/QOpenSys/etc/openssh_password_script.sh') + MBROPT(*REPLACE) + RCDDLM(*LF)
The program creates a file in Qtemp called FTP
The program writes records to the file
Then the program copies the file to the IFS file
When the program runs the variable &Linedata just before the RUNSQL line looks like this:
Code:
Insert into QTEMP/FTP (SRCDTA) values('' "#!/bin/sh"'')
Comment