Re: beginners-help@perl.org



Anirban Adhikary wrote:
Hi all

Hello,

Subject: beginners-help@xxxxxxxx

Please put the subject of your email on the Subject line.

I want to assign the each column of the following file in a separate
variable.

2864 oracle 0.0
0.2/home/oracle/u01/app/oracle/product/10.2.0/db_1/inventory/bin/tnslsnr
LISTENER -inherit
2872 oracle 0.0 0.6 ora_pmon_orcl
2874 oracle 0.0 0.5 ora_psp0_orcl
2876 oracle 0.0 1.2 ora_mman_orcl
2878 oracle 0.0 4.4 ora_dbw0_orcl
2880 oracle 0.0 1.7 ora_lgwr_orcl
2882 oracle 0.0 1.0 ora_ckpt_orcl
2884 oracle 0.0 5.0 ora_smon_orcl
2886 oracle 0.0 0.8 ora_reco_orcl
2888 oracle 0.0 2.3 ora_cjq0_orcl
2890 oracle 0.0 4.7 ora_mmon_orcl
2892 oracle 0.0 0.7 ora_mmnl_orcl
2894 oracle 0.0 0.5 ora_d000_orcl
2896 oracle 0.0 0.5 ora_s000_orcl
2904 oracle 0.0 0.5 ora_qmnc_orcl
2922 oracle 0.0 2.2 ora_q000_orcl
2924 oracle 0.0 0.5 ora_q001_orcl
20186 oracle 0.0 5.3 oracleorcl (LOCAL=NO)
22556 root 0.0 0.1 sshd: oracle [priv]
22558 oracle 0.0 0.0 sshd: oracle@pts/7
22559 oracle 0.0 0.0 -bash
22877 oracle 0.0 0.9 ora_j000_orcl

For this I used the following code

#!/usr/bin/perl -w

@arr1 = qw/java oracle/;
@arr2 = `ps -eo pid,user,pcpu,pmem,args | grep -v grep | grep $arr1[1]`;
$length= $#arr2;

for($i=0;$i<=$length;$i++)
{
chomp;
$val=$arr2[$i];
#print $val."\n";
@arr = split(/\s+/,$val);
print $arr[1]."\n";

But I am not getting the desired output.

This may work better:

#!/usr/bin/perl
use warnings;
use strict;

my $user = 'oracle';

open my $ps, '-|', 'ps', '-eo', 'pid,user,pcpu,pmem,args'
or die "Cannot open 'ps' pipe: $!";

while ( my $line = <$ps> ) {
my @fields = split ' ', $line, 5;
print $fields[ 1 ] if $fields[ 1 ] eq $user;
}

close $ps or warn $! ? "Error closing 'ps' pipe: $!"
: "Exit status $? from 'ps'";

__END__


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.



Relevant Pages

  • RE: Oracle Auditing
    ... A few things about Oracle and the 'listener' service. ... accepts and manages connections from the client to the Oracle database. ... WLAN by understanding these threats, ...
    (Pen-Test)
  • [NEWS] Vulnerability in Oracle 9i Database Server Leads to Remote Compromise
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... Oracle version 9 ... functions exported by operating system libraries or Dynamic Link ... requests that the Listener load the relevant library, ...
    (Securiteam)
  • Re: Slow access to the data base.
    ... "fo" will access the DB without passing through a listener? ... the oracle executable - it is a good example of what to check. ... And that vendor doesn't handle some tcp stuff correctly, ... the database for security reasons hence all connections go through the ...
    (comp.databases.oracle.server)
  • Re: connect system/password@xe doesnt work
    ... I have a problem with my new Oracle XE installation. ... On the database server side, Oracle Networking uses a network listener to ... the Listener waits on port 1521. ...
    (comp.databases.oracle.server)
  • Re: about setting connection to local database from EM DBControl configure program through IPC
    ... It looks like you can reach the listener, ... ports other than the listener port. ... If you enable an Oracle Net Trace (see the Net Services Reference ... Instance "orcl", status READY, has 1 handlerfor this service... ...
    (comp.databases.oracle.server)