echo in qsh

pts.
Tags:
AS/400
I'm getting strange results from the echo command in qsh. When I run qsh interactivly, I can pipe the output of the echo command to a file (of the "Yes, you can print to a file in CL" fame). I can echo as many lines as I want to while interactive. When I try to run the same echo command in a CL, I can only write the first line of an empty file. If I try to run it a second time or it already has lines in it, it doesn't work AND RETURNS NO ERRORS! Here is my source : PGM PARM(&DATA &LIB &FILE &MEM) DCL &DATA *CHAR 100 VALUE(' ') DCL &LIB *CHAR 10 DCL &FILE *CHAR 10 DCL &MEM *CHAR 10 DCL &CMD *CHAR 512 CHGVAR VAR(&CMD) VALUE('ECHO "' *TCAT &DATA *TCAT + '" >> /QSYS.LIB/' *TCAT &LIB *TCAT '.LIB/' + *TCAT &FILE *TCAT '.FILE/' *TCAT &MEM + *TCAT '.MBR/') QSH CMD(&CMD) ENDPGM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Don’t have direct answer to echoing many tiles to a file under qsh, but if your target is writing to a file in cl, do it with SQL, it’s easyer !

something like this :

EXECUTESQL SQL(‘insert into mylib/mytable
select * from anotherlib/anothertable’)

or (tested)

EXECUTESQL SQL(‘CREATE TABLE QTEMP/TENLIBS AS (
SELECT DIOBLI, DIOBNM, DIOBTP, DIOBAT, DIOBTX, DIOBSZ
FROM QUSRSYS/QAEZDISK WHERE DIOBTP = ”LIB”
FETCH FIRST 10 ROWS ONLY) WITH DATA’)

you can find ExecuteSql at http://jplamontre.free.fr/jpltools.htm

=========================================================

I’m not sure why you are trying to do this other than somebody said you could. A facility really shouldn’t be used if you haven’t learned how it works. The echo utility isn’t intended to output to database files.

Maybe you should examine this program:
<pre>
pgm

crtlib RXTMP

crtpf RXTMP/RXTMP +
rcdlen( 80 )

addpfm RXTMP/RXTMP RXTMP

qsh cmd(‘echo “line 1″ | Rfile -wQ ”rxtmp/rxtmp(rxtmp)”’)
qsh cmd(‘echo “line 2″ | Rfile -waQ ”rxtmp/rxtmp(rxtmp)”’)

return

endpgm
</pre>
If you run it, try running this command afterward:
<pre>
qsh cmd(‘echo “line 3″ | Rfile -waQ ”rxtmp/rxtmp(rxtmp)”’)
</pre>
</pre>
Note that it doesn’t matter if the sequence happens in a single program or if the QSH utilities are run later. Make sure you know what all is in the RXTMP file, and then run:
<pre>
qsh cmd(‘echo “line 4″ | Rfile -wQ ”rxtmp/rxtmp(rxtmp)”’)
</pre>
Review the purpose of the Rfile utility before actually trying to use it in programs.

Tom

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following