真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

script命令怎么在Linux中使用

script 命令怎么在Linux中使用?針對這個問題,這篇文章詳細介紹了相對應(yīng)的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。

創(chuàng)新互聯(lián)建站專業(yè)為企業(yè)提供崇明網(wǎng)站建設(shè)、崇明做網(wǎng)站、崇明網(wǎng)站設(shè)計、崇明網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、崇明企業(yè)網(wǎng)站模板建站服務(wù),十年崇明做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。

1、script命令描述

script命令會記錄所有的操作到文件同時在屏幕上輸出,直到終止登陸的會話,或使用CRTL+D,或使用exit退出則停止記錄。

這個命令對于數(shù)據(jù)庫的升級或是重要設(shè)置的情形下使用可以用于后續(xù)查詢操作成功或失敗。
用法: $ script [upgrade.log]
如果未指定日志文件名的情形,自動生成日志文件名為typescript。
如果需要輸出到已經(jīng)存在的日志文件,則使用 -a 參數(shù),再接已經(jīng)存在日志文件名。
如果需要在輸出到日志文件的同時,也可以查看日志文件的內(nèi)容,可以使用 -f 參數(shù)。

# script 幫助描述
robin@SZDB:~> man script
NAME
    script - make typescript of terminal session

SYNOPSIS
    script [-a] [-c COMMAND] [-f] [-q] [-t] [file]

DESCRIPTION
    Script makes a typescript of everything printed on your terminal.  It is useful for students who need a hardcopy record of
    an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).

    If the argument file is given, script saves all dialogue in file.  If no file name is given, the typescript is saved in the
    file typescript.

    Options:

    -a      Append the output to file or typescript, retaining the prior contents.

    -c COMMAND
            Run the COMMAND rather than an interactive shell.  This makes it easy for a script to capture the output of a pro-
            gram that behaves differently when its stdout is not a tty.

    -f      Flush output after each write. This is nice for telecooperation: One person does `mkfifo foo; script -f foo' and
            another can supervise real-time what is being done using `cat foo'.

    -q      Be quiet.

    -t      Output timeing data to standard error. This data contains two fields, separated by a space. The first field indi-
            cates how much time elapsed since the previous output. The second field indicates how many characters were output
            this time. This information can be used to replay typescripts with realistic typing and output delays.

2、script命令用法示例

代碼如下:


a、script命令后接日志文件名
robin@SZDB:~> script test_logfile.log        #啟用script
Script started, file is test_logfile.log

 .................#中間操作省略
 
robin@SZDB:~> exit    #停止script
exit
Script done, file is test_logfile.log

#查看剛剛生成的日志文件
robin@SZDB:~> more test_logfile.log
Script started on Fri 26 Apr 2013 05:45:23 PM CST
robin@SZDB:~> sid  
bash: sid: command not found
robin@SZDB:~> . ~/.bash_profile
robin@SZDB:~> sid
ORA_CRS_HOME=/opt/oracle/product/10gR2/crs
ORACLE_PATH=.:/users/robin/dba_scripts/custom/sql
ORA_ASM_HOME=/opt/oracle/product/10gR2/asm
ORACLE_SID=SYBO2SZ
ORACLE_BASE=/users/oracle
ORACLE_HOME=/users/oracle/OraHome10g
robin@SZDB:~> sql    

SQL*Plus: Release 10.2.0.3.0 - Production on Fri Apr 26 17:46:12 2013

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.

Error accessing PRODUCT_USER_PROFILE
Warning:  Product user profile information not loaded!
You may need to run PUPBLD.SQL as SYSTEM

Connected to:
Oracle Database 10g Release 10.2.0.3.0 - 64bit Production

goex_admin@SYBO2SZ> alter session set current_schema=scott;

Session altered.

goex_admin@SYBO2SZ> select * from dept;

   DEPTNO DNAME          LOC
---------- -------------- -------------
       10 ACCOUNTING     NEW YORK
       20 RESEARCH       DALLAS
       30 SALES          CHICAGO
       40 OPERATIONS     BOSTON

goex_admin@SYBO2SZ> exit
Disconnected from Oracle Database 10g Release 10.2.0.3.0 - 64bit Production
robin@SZDB:~> exit
exit

Script done on Fri 26 Apr 2013 05:46:32 PM CST  

b、script 命下直接跟腳本名的示例
robin@SZDB:~> script -c retval.sh
Script started, file is typescript
7788 SCOTT ANALYST 7566 19870419 00:00:00 3100 20
Script done, file is typescript

#被執(zhí)行的shell腳本的內(nèi)容
# Author : Robinson
# Blog   : http://blog.csdn.ner/robinson_0612

robin@SZDB:~> more ~/dba_scripts/custom/bin/retval.sh
#!/bin/bash
RETVAL=`sqlplus -silent scott/tiger <SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF
SELECT * FROM emp WHERE ename='SCOTT';
EXIT;
EOF`
if [ -z "$RETVAL" ]; then
 echo "No rows returned from database"
 exit 0
else
 echo $RETVAL
fi

關(guān)于script 命令怎么在Linux中使用問題的解答就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道了解更多相關(guān)知識。


當前名稱:script命令怎么在Linux中使用
文章位置:http://weahome.cn/article/ipsdpo.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部