📄 commands.script
字号:
:xmp.Response--------<Result string>:exmp.:p.where :xph.<Result string>:exph. is any information that was returned fromthe STAF service request.:p.For example, the output of :xph.STAF LOCAL PING PING:exph. should be:xmp.Response--------PONG:exmp.:p.On an unsuccessful STAF request (i.e., a request with a non-zero returncode), the output from the STAF command will be as follows:xmp.Error submitting request, RC: <Return code>Additional info---------------<Result string>:exmp.:p.where :xph.<Return code>:exph. is the actual return code from the request,and :xph.<Result string>:exph. is any information returned from the request.:xph.<Result string>:exph. usually contains information that explains why theerror occurred. Note, the "Additional info" will only be present if a non-emptyresult string was returned. Additionally, you may refer to:hdref refid=retcode. for information about the :xph.<Return code>:exph.:p.For example, the output of :xph.STAF LOCAL SEM LIST:exph. should be:xmp.Error submitting request, RC: 7Additional info---------------You must have at least 1, but no more than 1 of the option(s), MUTEX EVENT:exmp.:note.If the :xph.<Result string>:exph. from a STAF command contains any nullcharacters, you can set the environment variable STAF_REPLACE_NULLSto any non-empty value. This will cause the STAF command to replace any nullcharacters in the :xph.<Result string>:exph. with the specified value.Otherwise, the :xph.<Result string>:exph. will be truncated at the first nullcharacter found.:p.When structured data (see :hdref refid=marshall.) is returned in the resultstrings above, the STAF command will automatically unmarshall the data andprint it in the most appropriate format. If the data is a:xph.<List> of <String>:exph., then each entry in the list will be printedon its own line. For example,:xmp.C:\> staf local fs list directory c:\Response--------AUTOEXEC.BATboot.iniCONFIG.SYSDocuments and Settingsi387IO.SYSMSDOS.SYSMy MusicNTDETECT.COMntldrPAGEFILE.SYSProgram FilesRecycledRECYCLERSystem Volume InformationtempWINNT:exmp.:p.If the data is a :xph.<Map>:exph. (or :xph.<Map:<Class>>:exph.) whichhas values which are all of type &stringObj., then each key/value pair willbe printed on its own line. For example,:xmp.C:\> staf local monitor list settingsResponse--------Max Record Size : 1024Resolve Message : DisabledResolve Message Var: Disabled:exmp.:p.The above two types of formatted output are frequently referred to as"default format".:p.If the data is a :xph.<List> of <Map:<Class>>:exph. where every item inthe list is an instance of the same map class, then the data will be printedout in a tabular format, called "table format". For example,:xmp.$ staf local handle list handlesResponse--------Handle Handle Name State Last Used Date-Time------ ------------------------------- ---------- -------------------1 STAF_Process InProcess 20040929-13:57:402 STAF/Service/STAFServiceLoader1 InProcess 20040929-16:06:475 STAF/Service/LOG InProcess 20040929-13:57:527 STAF/Service/RESPOOL InProcess 20040929-13:58:0451 STAF/Service/MONITOR InProcess 20040929-16:06:4757 STAF/Client Registered 20040929-16:09:35:exmp.:p.The column headings in the table format are determined using the display namespecified for each key. Short display names may be used as column headingsby the STAF executable when displaying the result in a tabular form if thetotal width of the display names exceeds 80 characters.:p.By default a single record in the table format will only display the first20 lines (the last line will show "(More...)" to indicate that there weremore lines in the record). You can override the maximum number of lines thatare displayed per record by setting the environment variableSTAF_TABLE_LINES_PER_RECORD to the maximum number of lines.:p.You can disable the output of tables by setting the environment variableSTAF_PRINT_NO_TABLES to any value. If you disable the output of tables, theirdata will show up in the more verbose mode (described below).:p.If the data is more complex than the above (or tables have been turned off),the output will be printed in a hierarchical nested format, called "verboseformat". The best way to describe it is with an example.:xmp.C:\> staf local sem query event TestResponse--------{ State : Reset Last Posted: { Machine : crankin3 Handle Name: STAF/Client Handle : 62 User : none://anonymous Date-Time : 20040929-16:20:56 } Last Reset : { Machine : crankin3 Handle Name: STAF/Client Handle : 65 User : none://anonymous Date-Time : 20040929-16:21:43 } Waiters : [ { Machine : crankin3 Handle Name: TestHandle Handle : 67 User : none://anonymous Date-Time : 20040929-16:22:16 } ]}:exmp.:p.You can change the amount of indentation used by setting the environmentvariable STAF_INDENT_DELTA to any non-negative integer.:p.You can use the -verbose option to force the use of the verbosemode on a command basis. For example,:xmp.C:\> staf -verbose local fs list directory c:\Response--------[ AUTOEXEC.BAT boot.ini CONFIG.SYS Documents and Settings i387 IO.SYS MSDOS.SYS My Music NTDETECT.COM ntldr PAGEFILE.SYS Program Files Recycled RECYCLER System Volume Information temp WINNT]:exmp.:p.You can force the exclusive use of the verbose mode by setting theenvironment variable STAF_PRINT_MODE to "verbose". For example,:xmp.C:\> set STAF_PRINT_MODE=verboseC:\> staf local fs list directory c:\Response--------[ AUTOEXEC.BAT boot.ini CONFIG.SYS Documents and Settings i387 IO.SYS MSDOS.SYS My Music NTDETECT.COM ntldr PAGEFILE.SYS Program Files Recycled RECYCLER System Volume Information temp WINNT]:exmp.:p.If you should ever need to get at the raw result string (instead of thestructured output), you can set the environment variable STAF_PRINT_MODE to "raw".For example,:xmp.C:\> set STAF_PRINT_MODE=rawC:\> staf local fs list directory C:/temp/docsResponse--------@SDT/*:267&colon.@SDT/{&colon.26::13&colon.map-class-map@SDT/{&colon.0&colon.@SDT/[10:218&colon.@SDT/$S:11&colon.STAFTcl.htm@SDT/$S:12&colon.STAFPerl.htm@SDT/$S:14&colon.STAFPython.htm@SDT/$S:7&colon.History@SDT/$S&colon.12&colon.STAFCMDS.htm@SDT/$S:11&colon.STAFFAQ.htm@SDT/$S:10&colon.STAFGS.pdf@SDT/$S:12&colon.STAFHome.htm@SDT/$S:10&colon.STAFRC.htm@SDT/$S:10&colon.STAFUG.htm:exmp.:p.Note, by default, any &stringObj. value that looks as though it, itself,is a marshalled data structure will be recursively unmarshalled. For example,if someone marshalls a data structure and uses the resultant string as themessage for a log request, and then you query the log, the data structurein the log message string will automatically be unmarshalled. If you wantto turn off this behavior from the command line, and, instead, see themarshalled string in the message, set the environment variableSTAF_IGNORE_INDIRECT_OBJECTS to any value.:h4 id=stafshs.Using the STAF command from shell-scripts:p.There are two special environment variables that can be used to make theSTAF command blend in with shell-scripts. The first is STAF_QUIET_MODE.Setting this environment variable to any non-null value will cause the STAFcommand to only output the :xph.<Result string>:exph. that the requestgenerated. For example, the "STAF local ping ping" command above would simplyreturn:xmp.PONG:exmp.:p.This makes it easy to call STAF from shell-scripts. For example,:xmp.export STAF_QUIET_MODE=1STAFResult=`STAF local ping ping`if [ $? -ne 0 ]; then echo "Non-zero return code from ping request";elif [ "$STAFResult" != "PONG" ]; then echo "Expected PONG, received $STAFResult";else echo "ping request succeeded"fi:exmp.:p.The second environment variable is STAF_STATIC_HANDLE. If this environmentvariable is set, the STAF command will use the handle number indicated by thisenvironment variable. This ensures that the shell-script can use the samehandle throughout its execution. You may obtain a static handle in one of twoways. The first is using the CREATE command of the HANDLE service(see :hdref refid=handcrt.). For example,:xmp.export STAF_STATIC_HANDLE=`STAF local handle create handle name "My Test"`:exmp.:p.In this case, you are responsible for deleting the shell-scripts handle priorto your shell-script exiting. For example,:xmp.STAF local handle delete handle $STAF_STATIC_HANDLE:exmp.:p.The second way is by using the STATICHANDLENAME option when starting yourscript throught the PROCESS service (see :hdref refid=procstr.). In this casethe STAF_STATIC_HANDLE environment variable will already be set for you. Inaddition, the handle will automatically be deleted by STAF when yourshell-script completes.:p.You can test for the existence of the STAF_STATIC_HANDLE environment variableto determine if your shell-script was started via STAF, or whether it wasstarted by hand from the command line.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -