Windows サービスの一覧と状態を表示 (VBScript)

net startだと起動しているサービスしか表示しない

サービスの一覧を表示するスクリプト

strComputerName = "\\."
strSQL = "select * from Win32_Service"
Set objServices = GetObject("winmgmts:{impersonationLevel=impersonate}!" & _
strComputerName & "\root\cimv2").ExecQuery(strSQL)
For Each s In objServices
WScript.Echo s.DisplayName & "," & s.State
Next

上記を保存して(例 getService.vbs)
DOS窓からCScript getService.vbs とやれば 一覧が表示される。

エクスプローラーからダブルクリックすると、サービス毎に
メッセージボックスが表示されてウザイので注意

Oracle ロールバックセグメントがActiveでダウンした場合の対応

■ Oracle ロールバックがActiveの時にダウンして起動しなくなった場合
ロールバックセグメントファイルを消失して、起動しなくなった場合)

A) セグメントを特定する

select
segment_name,
status
from
dba_rollback_segs
where
tablespace_name='undotbs_corrupt'
and
status = ‘NEEDS RECOVERY’;

B) init.oraで特定のロールバックセグメントをオフラインにする
#_OFFLINE_ROLLBACK_SEGMENTS=_SYSSMU9$

C) その後、再起動してロールバックセグメントをDrop

SQL> drop rollback segment "_SYSSMU22$";
Rollback segment dropped.

SQL > drop tablespace undotbs including contents and datafiles;
Tablespace dropped.

/

select
b.id1,
a.sid,
a.serial#,
b.type,
to_char(b.ctime / 60,'999999999.9') min,
decode(b.lmode,
1, 'NULL',
2, '行共有(SS)',
3, '行排他(SX)',
4, '共有(S)',
5, '共有行排他(SRX)',
6, '排他(X)',
'???') lmode,
decode(b.request,
1, 'NULL',
2, '行共有(SS)',
3, '行排他(SX)',
4, '共有(S)',
5, '共有行排他(SRX)',
6, '排他(X)',
'???') request
from v$session a, v$lock b
where a.sid = b.sid and
(b.id1, b.id2) in (
select d.id1,d.id2 from v$lock d
where
d.id1 = b.id1 and d.id2 = b.id2 and
d.request > 0
)
order by b.id1, b.ctime desc;

Oracle 全ロックを表示する

/*
全ロックを表示する (時間付き)
*/
select a.owner || '.' || a.object_name object,
decode(b.locked_mode,
1, 'NULL',
2, '行共有(SS)',
3, '行排他(SX)',
4, '共有(S)',
5, '共有行排他(SRX)',
6, '排他(X)',
'???' ) locked_mode,
to_char(c.ctime / 60,'99990.9') min,
b.oracle_username, b.os_user_name, b.process
from dba_objects a, v$locked_object b, v$lock c
where a.object_id = b.object_id and
b.session_id = c.sid and
b.xidsqn = c.id2 and
b.xidusn > 0;

PerlでCSVファイルの各項目の和を数えるサンプル

Perl サンプル

ファイル開く、HASH

#!c:/Perl/bin/perl.exe

print "処理開始\n";
print "\n\n";

%browser_target;

@targetfilename = ("agent_log.0","agent_log.1","agent_log.2","agent_log.3");

#ファイルの数だけ繰り返す
foreach my $item (@targetfilename) {
&sub_count($item);
}

#集計結果を表示
&sub_printhash();



sub sub_count {

my ($filename) = @_;

unless (open (IN, "< $filename")) {
print "Read open error ($file).\n";
exit (1);
}


#ファイルの内容をHASHにしてカウントアップさせる。
$nLoopCnt = 0;
while ( $line = ) {
$nLoopCnt += 1;
chomp($line);
#ブラウザの部分だけ抜き出す
my ($tmpdate,$target,$tmpip1) = split (/"/, $line);


$browser_target{$target} += 1;

}
close(IN);

print "ファイル ".$filename."読込み終了\n";
print "\n\n";

}


sub sub_printhash {

#HASHの内容の一覧を表示する

$nLoopCnt = 0;

foreach $key ( keys %browser_target ) {
print "種類:$key : 値:$browser_target{$key}", "\n";
$nLoopCnt += 1;
}

print "\n\n";

print "処理終了 ".$nLoopCnt."種類ありました";
print "\n\n";
}

exit(0);

MySQL Perl DBI サンプル

MySQL Perl DBI サンプル

■ INSERT 文
use DBI;

$user = 'test';
$passwd = 'test2001';
$db = DBI->connect('DBI:mysql:ATMARKIT:localhost', $user, $passwd);
$sth = $db->prepare("INSERT INTO list VALUES (1,'1st','memo 1st')");
$sth->execute;
$sth->finish;
$db->disconnect;


■ SELECT文

use DBI;

$user = 'test';
$passwd = 'test2001';
$db = DBI->connect('DBI:mysql:ATMARKIT:localhost', $user, $passwd);
$sth = $db->prepare("SELECT id, name, memo FROM list");
$sth->execute;
$num_rows = $sth->rows;
print "該当 $num_rows 件\n";
for ($i=0; $i<$num_rows; $i++) {
@a = $sth->fetchrow_array;
print "id=$a[0], name=$a[1] memo=$a[2] \n";
}
$sth->finish;
$db->disconnect;