QSH won’t write in batch
65 pts.
0
Q:
QSH won't write in batch
this is the code
this was written by Avi HECHT
and i got it from here :
http://search400.techtarget.com/tip/0,289483,sid3_gci1098569,00.html

AddEnvVar EnvVar(TM) Value(&RECORD) Replace(*YES)
ChgVar Var(&DATA) Value('ECHO $TM >>' *BCAT +
'/QSYS.LIB/' *TCAT &LIB *TCAT '.LIB/' +
*TCAT &FILE *TCAT '.FILE/' *TCAT &MEMBER +
*TCAT '.MBR')
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.
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_)
EndDo

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 o0o why won't it work in batch , cuz it says it does!
is there a way to fix it ?
ASKED: Dec 14 2007  2:53 PM GMT
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
0
65 pts.
0
A:
 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0
  • AddThis Social Bookmark Button
Last Answered: Dec 14 2007  2:53 PM GMT by Iordache   65 pts.
0
0
Discuss This Answer:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _



_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

TomLiotta   7990 pts.  |   Oct 29 2009  1:07AM GMT

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

 
0