Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1079739
  • 博文数量: 106
  • 博客积分: 9093
  • 博客等级: 中将
  • 技术积分: 2770
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-01 17:22
文章分类

全部博文(106)

文章存档

2014年(1)

2012年(29)

2011年(32)

2010年(20)

2008年(24)

分类: 系统运维

2011-10-11 09:58:33

我们可以用CL命令STRQSH或QSH来启动Qshell环境。STRQSH有一个参数叫CMD,缺省值是*none,意思是不执行任何Qshell命令。

当你运行STRQSH的时候,会发生什么事取决与下面三件事:

  1. Qshell是运行在一个batch job下还是一个interactive job下。
  2. 参数CMD是不是指定了一个Qshell命令。
  3. Qshell是不是已经存在于interactive job下。

稍后我们会讨论。

在interactive job下运行Qshell

CMD参数中不写任何Qshell命令的执行STRQSH的时候就是启动了一个interactive job为Qshell。如图:

                                                      QSH Command Entry                                         
  $                    

 

 

 

 

 

 

                                                                                          
===>___________________________________________________________________     ________________________________________________________________________

F3=Exit   F6=Print F9=Retrieve F12=Disconnect                                                                     
F13=Clear F17=Top  F18=Bottom  F21=CL command entry      

  • 输出区

panel title下面就是输出区,Qshell session开始时输出区是空的除了Qshell提示符$。

在输出区会列出你输入的Qshell命令及相应结果。如图:

                                                        QSH Command Entry                                     
  $                                                                                                           
>pwd                                                                                                         
  /home/dds1873                                                                                               
  $                                                                                                           
>ls                                                                                                          
  a.out   hello.c hello.o                                                                                     
  $     

 

 

 

 

                                                                                                     
===>___________________________________________________________________     ________________________________________________________________________ 
F3=Exit   F6=Print F9=Retrieve F12=Disconnect                                                                 
F13=Clear F17=Top  F18=Bottom  F21=CL command entry                                                           

 

  • 参数CMD

CMD参数可以输入5000个字符的Qshell命令。下面就是一个简单的例子:

STRQSH CMD('ls *.out')

这种情况,Qshell不会打开一个session的,直接执行了ls命令并结束,如图:

  a.out                                                                       
  Press ENTER to end terminal session.                       

 

 

                

===>___________________________________________________________________     ________________________________________________________________________  
                                                                        
F3=Exit F4=End of File F6=Print F9=Retrieve F17=Top                           
F18=Bottom  F19=Left   F20=Right F21=User Window                              

 

在batch job下运行Qshell

我们可以有限制的运行Qshell在batch job下。如:

  • 没有输入请求
  • 如果想把你执行的命令结果输出的时候

下面就是一个运行Qshell命令在batch模式下的例子:

SBMJOB CMD(QSH CMD('ls *.out')) JOB(LISTFILE)

如果Qshell的CMD参数为*none,Qshell将不做任何动作并且job结束。

重定位Qshell输出

在V5R2,我们可以使用环境变量QIBM_QSH_CMD_OUTPUT来控制Qshell的输出目的地:

环境变量QIBM_QSH_CMD_OUTPUT允许的值有:

  1. NONE:丢掉输出
  2. STDOUT (default):直接指向c运行时终端session
  3. FILE=name:输出到指定的IFS文件name中,如果存在将覆盖原有内容,IFS文件将保存在当前的directory中
  4. FILEAPPEND=name:追加到文件name中

下面就是一个将输出输出到文件的例子:

ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE('FILE=lsout.txt')

STRQSH CMD('ls *.out')

进入Qshell,用pwd命令查看当前directory,用ls查看当前directory中的lsout.txt文件,用cat查看lsout.txt的内容。如图:

                                                        QSH Command Entry                                              
  $                                                                                                                    
> pwd                                                                                                                  
  /home/dds1873                                                                                                        
  $                                                                                                                    
> ls                                                                                                                   
  a.out           hello.c         hello.o         lsout.txt                                                            
  $                                                                                                                    
> cat lsout.txt                                                                                                        
  a.out                                                                                                                
  $      

 

 

                                                                                                             
===>___________________________________________________________________     ________________________________________________________________________                                                                                                            
F3=Exit   F6=Print F9=Retrieve F12=Disconnect                                                                          
F13=Clear F17=Top  F18=Bottom  F21=CL command entry                                                                    

 

当让也可以输出到数据文件中,但只能是程序描述的数据文件。例子如下:

ADDENVVAR ENVVAR(QIBM_QSH_CMD_OUTPUT) VALUE('FILE=/qsys.lib/ptrlib.lib/lsout.file/lsout.mbr')

CRTPF FILE(PTRLIB/LSOUT) RCDLEN(24)

STRQSH CMD('ls *.out')

用命令DSPPFM FILE(PTRLIB/LSOUT)  查看结果。

数据文件的每行数据的结尾是十六进制的25。

  • 进程

在unix下,一个进程就是一个正在运行的程序。Qshell的解释器就是一个进程。每个utility不是内置的命令,所以他们运行在自己进程中。在Qshell下,每个进程运行在自己的job下,所以进程和job可以互换。

  • 终端会话

终端会话看起来是一个interactive会话,但不完全是,是一组job。
当Qshell启动,OS/400会启动一个名为QZSHSH的batch-mmediate job来运行Qshell的解释器。此时,共有连个job,interactive job和batch-immediate job。如果要是执行了一个subshell或utility的话,Qshell会启动名为QP0ZSPWP的额外job如图:

                                                        QSH Command Entry                                                         
  $                                                                                                                               
> system "wrkusrjob"                                                                                                              
    5722SS1 V5R4M0 060210                   Work with User Jobs                                    10/10/11 20:43:25        Page  
   1                                                                                                                              
                                                                                                      System: RCHASA24            
    User . . . . . :  C210408            Status . . . . . . . :  *ALL             Job type . . . . . :  *ALL                      
                                                                                       -----Schedule-----                         
      Job Name     User         Number   Type      -----Status-----   Function         Date       Time                            
      QPADEV002G   C210408      391979   INTER     OUTQ                                                                           
      QPADEV002N   C210408      874543   INTER     ACTIVE             CMD-QSH                                                     
      QPADEV003R   C210408      438454   INTER     OUTQ                                                                           
      QP0ZSPWP     C210408      874873   BATCHI    ACTIVE             PGM-SYSTEM                                                  
      QZSHSH       C210408      874630   BATCHI    ACTIVE             PGM-QZSHSH                                                  
                             * * * * *  E N D  O F  L I S T I N G  * * * * *                                                      
                                                      RCHASA24                                                                    
  $    

 

                                                                                                                          

===>___________________________________________________________________     ________________________________________________________________________                                                                                                                                                                                                                                           
F3=Exit   F6=Print F9=Retrieve F12=Disconnect                                                                                     
F13=Clear F17=Top  F18=Bottom  F21=CL command entry                                                                               

 

可以用Qshell命令ps来显示进程的信息,如图:

                                                        QSH Command Entry                                               
    User . . . . . :  C210408            Status . . . . . . . :  *ALL             Job type . . . . . :  *ALL            
                                                                                       -----Schedule-----               
      Job Name     User         Number   Type      -----Status-----   Function         Date       Time                  
      QPADEV002G   C210408      391979   INTER     OUTQ                                                                 
      QPADEV002N   C210408      874543   INTER     ACTIVE             CMD-QSH                                           
      QPADEV003R   C210408      438454   INTER     OUTQ                                                                 
      QP0ZSPWP     C210408      874873   BATCHI    ACTIVE             PGM-SYSTEM                                        
      QZSHSH       C210408      874630   BATCHI    ACTIVE             PGM-QZSHSH                                        
                             * * * * *  E N D  O F  L I S T I N G  * * * * *                                            
                                                      RCHASA24                                                          
  $                                                                                                                     
> ps                                                                                                                    
       PID DEVICE       TIME FUNCTION       STATUS    JOBID                                                             
     37191 qpadev002n  00:00 cmd-qsh        dspa      874543/c210408/qpadev002n                                         
     37192 -           00:00 pgm-qzshsh     evtw      874630/c210408/qzshsh                                             
     37331 -           00:00 pgm-ps         run       889523/c210408/qp0zspwp                                           
  $  

                                                                                                                   
                                                                                                                

===>___________________________________________________________________     ________________________________________________________________________                                                                                                                                                                                                                                           
F3=Exit   F6=Print F9=Retrieve F12=Disconnect                                                                                     
F13=Clear F17=Top  F18=Bottom  F21=CL command entry                                                                               

-----------------

OVER

欢迎讨论

阅读(2882) | 评论(2) | 转发(1) |
给主人留下些什么吧!~~

niuhua772011-11-21 10:20:42

pantierui: 博文登上cu首页了。庆祝一下。哈哈。.....
送上一份迟到的祝贺吧

pantierui2011-10-11 15:10:48

博文登上cu首页了。庆祝一下。哈哈。