powershell_读取ORA错误脚本

#过滤oracle警告日志文件ORA-错误
$c=Get-Content C:\script.txt | select-string -pattern "ora-"
 
#判断ORA-错误存在条件
#若$c返回值为null,则输出1返回值结束循环
    if ( $c -eq  $null )

    {
        write-host "STATE_OK" 
        $STATE_OK  = {return 1;}
        $b = &$STATE_OK 
        $b
 
	
    }
#若$c返回值不为空,则复制oracle警告日志,清空原警告日志,返回0结束循环
    else 
    {
            copy C:\script.txt  C:\scriptbak.txt   

            
            write-host "STATE_ERROR" 
            write-host "$c" 
            " " > C:\script.txt
            $STATE_CRITICAL  = {return 0;Write-Host  "$c" }

            $a = &$STATE_CRITICAL 

            $a
 
    } 

你可能感兴趣的:(oracle,c,脚本,null,powershell)