<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Shell Script problem in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887269#M845142</link>
    <description>Thanks Geoff, I'm using ksh...&lt;BR /&gt;&lt;BR /&gt;I want to know How to extract son substrings inside string... Maybe sed...</description>
    <pubDate>Tue, 22 Feb 2005 11:31:48 GMT</pubDate>
    <dc:creator>GerGon</dc:creator>
    <dc:date>2005-02-22T11:31:48Z</dc:date>
    <item>
      <title>Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887266#M845139</link>
      <description>Hi gurus..&lt;BR /&gt;&lt;BR /&gt;I want to know who access Oracle database by sqlplus, I want to do it, get the user out from listener.log file and then kill his session.&lt;BR /&gt;&lt;BR /&gt;++++I have one file listener.log with similar format like:&lt;BR /&gt;asfd(sid=xx)xdxs(prg=sql)(user=yy)(wii3id)ase2&lt;BR /&gt;asfd(sid=xx)xs(prg=forms)(user=y1)(wii3id)ased&lt;BR /&gt;asfd(sid=xx)xdxs(prg=RWD)(user=y2)(wii3id)as82&lt;BR /&gt;asfd(sid=xx)xdxs(prg=sql)(user=y3)(wii3id)asv2&lt;BR /&gt;+++ I execute cat listener.log|grep -i sql &amp;gt; f1&lt;BR /&gt;asfd(sid=xx)xdxs(prg=sql)(user=yy)(wii3id)ase2&lt;BR /&gt;asfd(sid=xx)xdxs(prg=sql)(user=y3)(wii3id)asv2&lt;BR /&gt;+++ I want to extract wich user used sqlplus,&lt;BR /&gt;+++ I'm using strstr but it fails,msg:&lt;BR /&gt;sel=`cat f1`&lt;BR /&gt;for i in $sel&lt;BR /&gt;do&lt;BR /&gt; var1=`strstr($i,"USER=")` &lt;BR /&gt; echo $var1 &amp;gt;&amp;gt; file1&lt;BR /&gt;done&lt;BR /&gt;./killsql[7]: syntax error at line 1 : `(' unexpected&lt;BR /&gt;+++ What's wrong???&lt;BR /&gt;&lt;BR /&gt;*** I want to extract: the user who access by sqlplus program and kill his session.&lt;BR /&gt;&lt;BR /&gt;Any other idea be welcome..&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 22 Feb 2005 11:00:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887266#M845139</guid>
      <dc:creator>GerGon</dc:creator>
      <dc:date>2005-02-22T11:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887267#M845140</link>
      <description>Are you using ksh or sh?&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Feb 2005 11:29:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887267#M845140</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-02-22T11:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887268#M845141</link>
      <description>Gergon,&lt;BR /&gt;&lt;BR /&gt;It can be done with awk&lt;BR /&gt;&lt;BR /&gt;cat f1 | awk -F"user" '{print $2}' | awk -F"=" '{print $2}' &amp;gt;file1&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Rajeev</description>
      <pubDate>Tue, 22 Feb 2005 11:30:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887268#M845141</guid>
      <dc:creator>Rajeev Tyagi</dc:creator>
      <dc:date>2005-02-22T11:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887269#M845142</link>
      <description>Thanks Geoff, I'm using ksh...&lt;BR /&gt;&lt;BR /&gt;I want to know How to extract son substrings inside string... Maybe sed...</description>
      <pubDate>Tue, 22 Feb 2005 11:31:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887269#M845142</guid>
      <dc:creator>GerGon</dc:creator>
      <dc:date>2005-02-22T11:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887270#M845143</link>
      <description>Hi,&lt;BR /&gt;my listener.log file doesn't look like your example. So how about:&lt;BR /&gt;ps -ef | grep -e ' sqlplus ' | grep -v grep | cut -d' ' -f2&lt;BR /&gt;This should give you the processes of all the sqlplus sessions.&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Feb 2005 11:36:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887270#M845143</guid>
      <dc:creator>Peter Godron</dc:creator>
      <dc:date>2005-02-22T11:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887271#M845144</link>
      <description>can not tell if your listner.log file is using as a seperator, but you could do somehting like this:&lt;BR /&gt;&lt;BR /&gt;oldIFS="$IFS"&lt;BR /&gt;IFS="()\n"&lt;BR /&gt;cat listener.log |&lt;BR /&gt;while read w1 w2 w3 w4 w5 w6 rest&lt;BR /&gt;do&lt;BR /&gt;print $w1 $w2 $w3 $w4 $w5 $w6&lt;BR /&gt;prg=${w4:#*=}&lt;BR /&gt;user=${w6:#*=}&lt;BR /&gt;print $prg $user&lt;BR /&gt;if [[ "$prg" = "sql" ]] ;then&lt;BR /&gt;print "die $user"&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;IFS="$IFS"&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Feb 2005 11:39:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887271#M845144</guid>
      <dc:creator>c_51</dc:creator>
      <dc:date>2005-02-22T11:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887272#M845145</link>
      <description>This is not the best script but it works :-)&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;for i in $(cat f1)&lt;BR /&gt;do&lt;BR /&gt;echo $i | grep user | awk 'FS="=" {print $4}' | awk ' FS=")" {print $1}' &amp;gt;&amp;gt; file1&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Feb 2005 11:40:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887272#M845145</guid>
      <dc:creator>Jannik</dc:creator>
      <dc:date>2005-02-22T11:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887273#M845146</link>
      <description>I try with all your efforts, but they did not work...&lt;BR /&gt;&lt;BR /&gt;When I do the first filter with grep the  out file only have one large string...&lt;BR /&gt;&lt;BR /&gt;It's better, How do I do to get a substring from string, ie:&lt;BR /&gt;&lt;BR /&gt;a1='geosphere(user=delta)green(prg=alfa)blue'&lt;BR /&gt;&lt;BR /&gt;Grep see it like one string (no separated), I need to get or extract "delta" and "alfa", BUT remenber the fix parameter is user and prg, because delta and alfa are variables.&lt;BR /&gt;&lt;BR /&gt;Then, I process the file properly...&lt;BR /&gt;&lt;BR /&gt;Can help me please...&lt;BR /&gt;Thanks..</description>
      <pubDate>Tue, 22 Feb 2005 12:31:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887273#M845146</guid>
      <dc:creator>GerGon</dc:creator>
      <dc:date>2005-02-22T12:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887274#M845147</link>
      <description>Peter, I know that the listener.log have a different format.&lt;BR /&gt;&lt;BR /&gt;But, if I know How to get a substring from string a can do it with listener.log&lt;BR /&gt;&lt;BR /&gt;However, if someone have Oracle and want to review the original file listener.log of your Oracle Environment and give me some advice, thanks.. &lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 22 Feb 2005 12:41:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887274#M845147</guid>
      <dc:creator>GerGon</dc:creator>
      <dc:date>2005-02-22T12:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887275#M845148</link>
      <description>Can't seem to get the strstr to work...&lt;BR /&gt;&lt;BR /&gt;How about this ugly hack:&lt;BR /&gt;&lt;BR /&gt;cat f1 |awk -Fuser= '{print $2}' |awk -F")" '{print $1}'&lt;BR /&gt;&lt;BR /&gt;In a script:&lt;BR /&gt;&lt;BR /&gt;#/bin/sh&lt;BR /&gt;for user in `cat f1 |awk -Fuser= '{print $2}' |awk -F")" '{print $1}'`&lt;BR /&gt;do&lt;BR /&gt;echo $user&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Rgds...Geoff&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Feb 2005 12:48:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887275#M845148</guid>
      <dc:creator>Geoff Wild</dc:creator>
      <dc:date>2005-02-22T12:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887276#M845149</link>
      <description>Hi Gergon,&lt;BR /&gt;I am successful with you single line question asked later:&lt;BR /&gt;&lt;BR /&gt;#cat file1&lt;BR /&gt;a1='geosphere(user=delta)green(prg=alfa)blue'&lt;BR /&gt;&lt;BR /&gt;Now in two shots i get the required output:&lt;BR /&gt;&lt;BR /&gt;#cat file1 | cut -d "(" -f 2 | cut -d ")" -f 1&lt;BR /&gt;&lt;BR /&gt;user=delta&lt;BR /&gt;&lt;BR /&gt;# cat file1 | cut -d ")" -f 2 | cut -d "(" -f 2&lt;BR /&gt;&lt;BR /&gt;prg=alfa&lt;BR /&gt;&lt;BR /&gt;Looks funny :))&lt;BR /&gt;but still does that help ??&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Feb 2005 12:57:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887276#M845149</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2005-02-22T12:57:14Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887277#M845150</link>
      <description>Well if the user does not user SQLNet you won't find him/her in the listener.log&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;export ORACLE_SID=&lt;SID&gt;&lt;BR /&gt;sqlplus user/passwd&lt;BR /&gt;&lt;BR /&gt;this is not in the listener.log&lt;BR /&gt;&lt;BR /&gt;you must go into the database qnd query the system views :&lt;BR /&gt;try :&lt;BR /&gt;select * from v$session where module='SQL*Plus'&lt;BR /&gt;&lt;BR /&gt;then find SID,serial# and kill session at oracle level.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Jean-Luc&lt;/SID&gt;</description>
      <pubDate>Tue, 22 Feb 2005 13:03:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887277#M845150</guid>
      <dc:creator>Jean-Luc Oudart</dc:creator>
      <dc:date>2005-02-22T13:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887278#M845151</link>
      <description>Maybe it's time to go for perl. What you want to do is exactly what perl was designed for.&lt;BR /&gt;&lt;BR /&gt;Here is a try :&lt;BR /&gt;&lt;BR /&gt;------ connection.pl ---&lt;BR /&gt;#!/opt/perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;while (&lt;STDIN&gt;) {&lt;BR /&gt;  chomp;&lt;BR /&gt;  @equals=split /[()]/;&lt;BR /&gt;  $host="";&lt;BR /&gt;  $user="";&lt;BR /&gt;  $service="";&lt;BR /&gt;  foreach $equality (@equals) {&lt;BR /&gt;    ($key,$value)=split /=/,$equality;&lt;BR /&gt;    if ($key eq "HOST") { $host=$value; }&lt;BR /&gt;    elsif ($key eq "USER") { $user=$value; }&lt;BR /&gt;    elsif ($key eq "SERVICE_NAME") { $service=$value; }&lt;BR /&gt;  }&lt;BR /&gt;  print "Connection from ${user}\@${host} to ${service}\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;------ usage ---&lt;BR /&gt;&lt;BR /&gt;tail listener.log | ./connections.pl&lt;BR /&gt;Connection from scott@127.0.0.1 to oradb1&lt;BR /&gt;Connection from system@192.17.38.1 to prod&lt;BR /&gt;Connection from fred@192.17.1.1 to oradb1&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;----- end ---&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;&lt;/STDIN&gt;</description>
      <pubDate>Tue, 22 Feb 2005 13:09:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887278#M845151</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2005-02-22T13:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887279#M845152</link>
      <description>Fred, &lt;BR /&gt;&lt;BR /&gt;Your solution looks good and works fine, BUT, How can i  filter only user that connect via: sql* that mean:&lt;BR /&gt;sqlplusw, sqlplus32 and SQLNav?????&lt;BR /&gt;&lt;BR /&gt;Excuseme but don't know Perl, otherwisse, I only do the correction..&lt;BR /&gt;&lt;BR /&gt;Thanks..&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 22 Feb 2005 14:40:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887279#M845152</guid>
      <dc:creator>GerGon</dc:creator>
      <dc:date>2005-02-22T14:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887280#M845153</link>
      <description>Am I missing something? Are you just trying to get the sql user for output?&lt;BR /&gt;&lt;BR /&gt;# egrep "prg=sql" f1 | cut -d= -f4|cut -d\) -f1              &lt;BR /&gt;yy&lt;BR /&gt;y3&lt;BR /&gt;# &lt;BR /&gt;&lt;BR /&gt;Add a for loop around it&lt;BR /&gt;&lt;BR /&gt;# for USER in `egrep "prg=sql" f1 | cut -d= -f4|cut -d\) -f1`&lt;BR /&gt;do&lt;BR /&gt;    sqlkill $USER&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;## I just did that on my SUN workstation. If that doesn't work on your HP use grep -e"prg=sql" instead of egrep "prg=sql"&lt;BR /&gt;&lt;BR /&gt;&lt;SVF&gt;&lt;/SVF&gt;</description>
      <pubDate>Wed, 23 Feb 2005 01:55:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887280#M845153</guid>
      <dc:creator>Steve Faidley</dc:creator>
      <dc:date>2005-02-23T01:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887281#M845154</link>
      <description>This version seems to match your requirements. I have added a criteria on SID as well as SERVICE_NAME because there are still old tnsnames.ora files :)&lt;BR /&gt;&lt;BR /&gt;This will catches any line were program name mathes sql Sql sQl sqL SQl, etc. Note that regarding my tests, there are lots of programs named *sql*...&lt;BR /&gt;&lt;BR /&gt;if you want to have only those starting with sql, you will need to add a ^ at the begining of regexp.&lt;BR /&gt;&lt;BR /&gt;------ connection.pl ---&lt;BR /&gt;#!/opt/perl/bin/perl&lt;BR /&gt;&lt;BR /&gt;while (&lt;STDIN&gt;) {&lt;BR /&gt;  chomp;&lt;BR /&gt;  @equals=split /[()]/;&lt;BR /&gt;  $host="";&lt;BR /&gt;  $user="";&lt;BR /&gt;  $service="";&lt;BR /&gt;  $program="";&lt;BR /&gt;  foreach $equality (@equals) {&lt;BR /&gt;    ($key,$value)=split /=/,$equality;&lt;BR /&gt;    if ($key eq "HOST") { $host=$value; }&lt;BR /&gt;    elsif ($key eq "USER") { $user=$value; }&lt;BR /&gt;    elsif ($key eq "SERVICE_NAME" or $key eq "SID") { $service=$value; }&lt;BR /&gt;    elsif ($key eq "PROGRAM") { $program=$value; }&lt;BR /&gt;  }&lt;BR /&gt;  $program=~ m/[Ss][Qq][Ll]/g;&lt;BR /&gt;  print "Connection from ${user}\@${host} to ${service} with ${program}\n" if pos($program);&lt;BR /&gt;}&lt;BR /&gt;------ end ---&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;&lt;/STDIN&gt;</description>
      <pubDate>Wed, 23 Feb 2005 04:55:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887281#M845154</guid>
      <dc:creator>Fred Ruffet</dc:creator>
      <dc:date>2005-02-23T04:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887282#M845155</link>
      <description>for line in `cat listener.log|grep prg=sql`&lt;BR /&gt;do&lt;BR /&gt;temp=${line##*prg=sql\)\(user=}&lt;BR /&gt;sqluser=${temp%%\)\(*}&lt;BR /&gt;echo "user $sqluser used sql"&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;The above will find the user that used sql.&lt;BR /&gt;Am I right in assuming that the "(sid=xx)" part of the line would actually contain the PID of their session? i.e. (sid=4509)?&lt;BR /&gt;&lt;BR /&gt;If so, try this:&lt;BR /&gt;&lt;BR /&gt;for line in `cat listener.log|grep prg=sql`&lt;BR /&gt;do&lt;BR /&gt;temp=${line##*prg=sql\)\(user=}&lt;BR /&gt;sqluser=${temp%%\)\(*}&lt;BR /&gt;echo "user $sqluser used sql... Killing him."&lt;BR /&gt;temp=${line##*sid=}&lt;BR /&gt;victim=${temp%%\)*}&lt;BR /&gt;echo "victim is ${victim}"&lt;BR /&gt;kill $victim&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Feb 2005 04:58:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887282#M845155</guid>
      <dc:creator>Gordon  Morrison_1</dc:creator>
      <dc:date>2005-02-23T04:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Shell Script problem</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887283#M845156</link>
      <description>Thanks a lot Everybody in this thread....&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Feb 2005 08:51:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-problem/m-p/4887283#M845156</guid>
      <dc:creator>GerGon</dc:creator>
      <dc:date>2005-02-23T08:51:30Z</dc:date>
    </item>
  </channel>
</rss>

