Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1294194
  • 博文数量: 287
  • 博客积分: 11000
  • 博客等级: 上将
  • 技术积分: 3833
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-16 08:43
文章分类
文章存档

2013年(15)

2012年(17)

2011年(17)

2010年(135)

2009年(85)

2008年(18)

分类: 系统运维

2009-05-07 08:03:21

RPGIV编程问题百解(25)在QSH下,发送SpoolFiles
 
问题:
 
I got a program that does following steps.
1) Copy spool files to data base file (using CPYSPLF command)
2) Create folder (CRTFLR command)
3) Copy the data base file to document in the folder (using CPYTOPCD command)
4) Change the document descriptuion
5) E-mail files using SNDDST
 
Recently, we had a size problem. I was advised to (from this forum) zip the
file before sending (using Strqsh jar command)
My questing is,
How do I specify the path in the strqsh command? I am not sure how to specify
folder library etc.
Appreciate if you could show me some code example..
Thanks in advance
 
回答1:
 
Don't know if this is still the case, but when I wrote this it jar wouldn't work
in /QDLS. I create the stream file in another directory, zip it there, then move
it to QDLS for SNDDST.
 
I also had an authority issue. jar creates the zip with owner's authority set to
*RW. This causes the DLTDLO to fail the next time you run this, so need to
change the authority to *RWX.
 
/* Prepare file */
   CRTPF      FILE(QTEMP/SPLF) RCDLEN(133) SIZE(*NOMAX)
   CPYSPLF    FILE(xxx) TOFILE(QTEMP/SPLF) ...
/* Convert to stream file */
   RMVLNK     OBJLNK('/home/email/splf.txt')
   MONMSG     MSGID(CPFA000)
   CPYTOSTMF  FROMMBR('/QSYS.LIB/QTEMP.LIB/SPLF.FILE/SPLF.MBR') +
                TOSTMF('/home/email/splf.txt') STMFOPT(*REPLACE) +
                STMFCODPAG(*STDASCII)
   DLTF       FILE(QTEMP/SPLF)
   MONMSG     MSGID(CPF0000)
/* Compress the stream file */
   QSH        CMD('cd /home/email;jar cMf SPLF.ZIP splf.txt')
   CHGAUT     OBJ('/home/email/SPLF.ZIP') USER(owner) DTAAUT(*RWX)
   RMVLNK     OBJLNK('/home/email/splf.txt')
   MONMSG     MSGID(CPFA000)
/* Move to QDLS so it can be e-mailed */
   DLTDLO     DLO(SPLF.ZIP) FLR(EMAIL)
   MONMSG     MSGID(CPF0000)
   MOV        OBJ('/home/email/SPLF.ZIP') TODIR('/QDLS/EMAIL')
/* Send e-mail */
   CHGDOCD    DOC(SPLF.ZIP) FLR(EMAIL) DOCD('xxx')
   SNDDST     TYPE(*DOC) TOUSRID((user addr)) DSTD('xxx') MSG('Here''s +
                your report.') DOC(SPLF.ZIP) FLR(EMAIL)
回答2:
 
Oh, guess I didn't actually answer the question. There are several ways you can
deal with the path for QSH. Here are a few obvious ones:
 
* The CL can change directory before using QSH with CD or CHGCURDIR.
* The jar command in the QSH CMD() could use full paths to the files involved.
QSH CMD('jar cMf /home/email/SPLF.ZIP /home/email/splf.txt')
* You could write a small script that would cd and jar. The QSH CMD() would name
the script. (Seems like a lot of work for such a small script though.)
* QSH allows multiple commands separated by semicolons. This is what I did in
the sample code.
 
3rd and 4th options have the advantage of not changing the job's current
directory. When you're in QShell (either by QSH or STRQSH), the current
directory is copied when the shell is initialized. Any cd's while you're in
QShell affect only QShell. When you exit the shell and return to the original
job, the original job's current directory is unchanged. (What happens in QShell,
stays in QShell?)
阅读(1232) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~