濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > Linux下通過(guò)script 命令記錄(數(shù)據(jù)庫(kù))操作步驟

Linux下通過(guò)script 命令記錄(數(shù)據(jù)庫(kù))操作步驟

熱門(mén)標(biāo)簽:制作地圖標(biāo)注 外呼系統(tǒng)怎么弄 商店地圖標(biāo)注外賣(mài)入駐 磁力導(dǎo)航地圖標(biāo)注 桂林市ai電銷機(jī)器人公司 地址高德地圖標(biāo)注 外呼系統(tǒng)鏈接 地圖標(biāo)注的牌子 新科火車(chē)站地圖標(biāo)注點(diǎn)

1、script命令描述


復(fù)制代碼
代碼如下:

script命令會(huì)記錄所有的操作到文件同時(shí)在屏幕上輸出,直到終止登陸的會(huì)話,或使用CRTL+D,或使用exit退出則停止記錄。
這個(gè)命令對(duì)于數(shù)據(jù)庫(kù)的升級(jí)或是重要設(shè)置的情形下使用可以用于后續(xù)查詢操作成功或失敗。
用法: $ script [upgrade.log]
如果未指定日志文件名的情形,自動(dòng)生成日志文件名為typescript。
如果需要輸出到已經(jīng)存在的日志文件,則使用 -a 參數(shù),再接已經(jīng)存在日志文件名。
如果需要在輸出到日志文件的同時(shí),也可以查看日志文件的內(nèi)容,可以使用 -f 參數(shù)。/p> p># script 幫助描述
robin@SZDB:~> man script
NAME
script - make typescript of terminal session/p> p>SYNOPSIS
script [-a] [-c COMMAND] [-f] [-q] [-t] [file]/p> p>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)./p> p> 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./p> p> Options:/p> p> -a Append the output to file or typescript, retaining the prior contents./p> p> -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./p> p> -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'./p> p> -q Be quiet./p> p> -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命令用法示例


復(fù)制代碼
代碼如下:

a、script命令后接日志文件名
robin@SZDB:~> script test_logfile.log #啟用script
Script started, file is test_logfile.log/p> p> .................#中間操作省略

robin@SZDB:~> exit #停止script
exit
Script done, file is test_logfile.log/p> p>#查看剛剛生成的日志文件
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 /p> p>SQL*Plus: Release 10.2.0.3.0 - Production on Fri Apr 26 17:46:12 2013/p> p>Copyright (c) 1982, 2006, Oracle. All Rights Reserved./p> p>Error accessing PRODUCT_USER_PROFILE
Warning: Product user profile information not loaded!
You may need to run PUPBLD.SQL as SYSTEM/p> p>Connected to:
Oracle Database 10g Release 10.2.0.3.0 - 64bit Production/p> p>goex_admin@SYBO2SZ> alter session set current_schema=scott;/p> p>Session altered./p> p>goex_admin@SYBO2SZ> select * from dept;/p> p> DEPTNO DNAME LOC
---------- -------------- -------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON/p> p>goex_admin@SYBO2SZ> exit
Disconnected from Oracle Database 10g Release 10.2.0.3.0 - 64bit Production
robin@SZDB:~> exit
exit/p> p>Script done on Fri 26 Apr 2013 05:46:32 PM CST /p> p>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/p> p>#被執(zhí)行的shell腳本的內(nèi)容
# Author : Robinson
# Blog : http://blog.csdn.ner/robinson_0612/p> p>robin@SZDB:~> more ~/dba_scripts/custom/bin/retval.sh
#!/bin/bash
RETVAL=`sqlplus -silent scott/tiger EOF
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

標(biāo)簽:湘西 衡陽(yáng) 衡陽(yáng) 六盤(pán)水 三門(mén)峽 仙桃 茂名 慶陽(yáng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Linux下通過(guò)script 命令記錄(數(shù)據(jù)庫(kù))操作步驟》,本文關(guān)鍵詞  Linux,下,通過(guò),script,命令,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Linux下通過(guò)script 命令記錄(數(shù)據(jù)庫(kù))操作步驟》相關(guān)的同類信息!
  • 本頁(yè)收集關(guān)于Linux下通過(guò)script 命令記錄(數(shù)據(jù)庫(kù))操作步驟的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    鸡西市| 台州市| 呈贡县| 滨海县| 镇平县| 永顺县| 广宁县| 称多县| 绥化市| 永嘉县| 奎屯市| 巍山| 彭州市| 元朗区| 衡山县| 宣恩县| 隆子县| 密云县| 金山区| 宝应县| 轮台县| 揭西县| 博白县| 新疆| 白水县| 双流县| 孝感市| 洪江市| 汉阴县| 乌拉特前旗| 凤山市| 仲巴县| 潜江市| 莲花县| 历史| 建始县| 庆阳市| 肃北| 法库县| 阜城县| 南召县|