QSH won’t write in batch

65 pts.
This is the code this was written by Avi HECHT and I got it from here:
AddEnvVar EnvVar(TM) Value(&RECORD) Replace(*YES)
ChgVar Var(&DATA) Value('ECHO $TM >>' *BCAT +
StrQsh Cmd(&DATA)
RmvEnvVar EnvVar(TM)
MonMsg MsgId(CPFA981)
The problems are these: First you need to create a file if it doesn't exist. This was solved through:
ChkObj Obj(&LIB/&FILE) ObjType(*FILE)
Monmsg MSGID(CPF9801) Exec(DO)
CrtPf File(&LIB/&FILE) RcdLen(512)
MonMsg MsgId(CPF0000) Exec(Goto ERROR_)
Second, it will only write the first line (the one that created the .MBR) after that it doesn't add anything. i'm talking about batch. When in interactive it works charms. Can anyone tell me why it won't work in batch, because it says it does! Is there a way to fix it?

Answer Wiki

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

Set ECHO in the variable in lower case like this.
ChgVar Var(&DATA) Value(‘echo $TM >>’ *BCAT +

Discuss This Question: 1  Reply

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.
  • TomLiotta
    I don't know why it doesn't work for you -- it works fine for me, adding a new line whenever I execute the echo utility again. First things first, you're using a utility that isn't intended to be run outside of the Qshell environment. If you are starting Qshell multiples times in a job, make sure you understand what the shell environment does. You need to understand relationships such as file descriptors and input/output streams; file descriptors might be opened/closed/used by other parts of the same program. Make sure you understand how system-wide environment variables might alter how shell utilities work. Make sure you understand how environment variables from a submitting job might affect environment variables in the submitted job. Make sure you understand how a Qshell environment might be created in a job and either re-used or destroyed. Best advice is to use something that is intended to write lines to a physical file. The link you posted includes reference to the Qshell db2 utility. And that utility is intended for updating physical files. Even better, don't use CL for trying to update files; use a language that supports file output. Echo can and does write to physical files. Just don't expect it to work all the time because it probably won't. There can be too many factors outside of your control. Tom
    125,585 pointsBadges:

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.

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


Share this item with your network: