<?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: Killing process id in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089067#M806533</link>
    <description>Have a look at this thread, and the ones linked fom it...&lt;BR /&gt;--&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x80771cc6003bd6118fff0090279cd0f9%2C00.html&amp;amp;admit=716493758+1065690431101+28353475" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x80771cc6003bd6118fff0090279cd0f9%2C00.html&amp;amp;admit=716493758+1065690431101+28353475&lt;/A&gt;&lt;BR /&gt;--&lt;BR /&gt;From dim and distant experience I think remsh does fummy things to "expect".&lt;BR /&gt;-- Graham</description>
    <pubDate>Thu, 09 Oct 2003 04:08:46 GMT</pubDate>
    <dc:creator>Graham Cameron_1</dc:creator>
    <dc:date>2003-10-09T04:08:46Z</dc:date>
    <item>
      <title>Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089065#M806531</link>
      <description>First of all, i want to:&lt;BR /&gt;1. Connect to a remote machine through it's IP address and login to it.&lt;BR /&gt;&lt;BR /&gt;       my code:&lt;BR /&gt;               spawn " telnet 10.10.x.x."&lt;BR /&gt;                  expect "login:"&lt;BR /&gt;                       send " Letme\r"&lt;BR /&gt;                   expect "assword:"&lt;BR /&gt;                        send " 123\r"&lt;BR /&gt;                expect "#"&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;2. Then find out if XXX programme is running&lt;BR /&gt;&lt;BR /&gt;                                send " [exec /bin/ps aux | grep XXX \r"&lt;BR /&gt;               (XXX is the programme i want to get its process ID, could&lt;BR /&gt;be apache etc)&lt;BR /&gt;&lt;BR /&gt;3. After the executing the above code, list of  process id of XXX&lt;BR /&gt;programme will be listed.&lt;BR /&gt;&lt;BR /&gt;What i want is to catch the first line of list and save it into the&lt;BR /&gt;variable, where i can then pick up the process id from it and then kill&lt;BR /&gt;it.&lt;BR /&gt;&lt;BR /&gt;I have also tried to pipe the out of this comamnd  send " [exec /bin/ps&lt;BR /&gt;aux | grep XXX \r" into the file, but the file can not be saved on the&lt;BR /&gt;remote machine.&lt;BR /&gt;&lt;BR /&gt;Can any one show me a good and working code&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Oct 2003 03:36:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089065#M806531</guid>
      <dc:creator>CWCW</dc:creator>
      <dc:date>2003-10-09T03:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089066#M806532</link>
      <description>How about&lt;BR /&gt; &lt;BR /&gt;kill `remsh 10.10.x.x ps -ef | grep XXX | awk 'print $2;exit}'`&lt;BR /&gt; &lt;BR /&gt;A bit dangerous though</description>
      <pubDate>Thu, 09 Oct 2003 04:00:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089066#M806532</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-10-09T04:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089067#M806533</link>
      <description>Have a look at this thread, and the ones linked fom it...&lt;BR /&gt;--&lt;BR /&gt;&lt;A href="http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x80771cc6003bd6118fff0090279cd0f9%2C00.html&amp;amp;admit=716493758+1065690431101+28353475" target="_blank"&gt;http://forums1.itrc.hp.com/service/forums/parseCurl.do?CURL=%2Fcm%2FQuestionAnswer%2F1%2C%2C0x80771cc6003bd6118fff0090279cd0f9%2C00.html&amp;amp;admit=716493758+1065690431101+28353475&lt;/A&gt;&lt;BR /&gt;--&lt;BR /&gt;From dim and distant experience I think remsh does fummy things to "expect".&lt;BR /&gt;-- Graham</description>
      <pubDate>Thu, 09 Oct 2003 04:08:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089067#M806533</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-10-09T04:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089068#M806534</link>
      <description>Mark's advise is indeed a little bit dangerous... the killing is done locally. Oops. :)&lt;BR /&gt;&lt;BR /&gt;I usuall kill like this:&lt;BR /&gt;&lt;BR /&gt;# kill $(UNIX95=1 ps -o pid= -C XXX)&lt;BR /&gt;&lt;BR /&gt;Remotely this would be:&lt;BR /&gt;&lt;BR /&gt;# remsh 10.10.x.x "kill $(UNIX95=1 ps -o pid= -C XXX)"&lt;BR /&gt;&lt;BR /&gt;Obviuously, you like using expect with telnet :-)... so this could be an option:&lt;BR /&gt;&lt;BR /&gt;spawn telnet 10.10.x.x&lt;BR /&gt;expect "login:"&lt;BR /&gt;send " Letme\r"&lt;BR /&gt;expect "assword:"&lt;BR /&gt;send " 123\r"&lt;BR /&gt;expect "#"&lt;BR /&gt;send "kill $(UNIX95=1 ps -o pid= -C XXX)\r"&lt;BR /&gt;expect "#"&lt;BR /&gt;&lt;BR /&gt;Best regards...&lt;BR /&gt; Dietmar.</description>
      <pubDate>Thu, 09 Oct 2003 06:31:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089068#M806534</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2003-10-09T06:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089069#M806535</link>
      <description>You are absolutely right Dietmar! Doh!  Perhaps that post should be removed&lt;BR /&gt; &lt;BR /&gt;Ok, in a valiant attempt to re-deem myself, how about&lt;BR /&gt;&lt;BR /&gt;$KILLPID=`remsh 10.10.x.x ps -ef | grep XXX | awk 'print $2;exit}`&lt;BR /&gt;remsh 10.10.x.x kill $KILLPID&lt;BR /&gt; &lt;BR /&gt;</description>
      <pubDate>Thu, 09 Oct 2003 06:42:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089069#M806535</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-10-09T06:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089070#M806536</link>
      <description>Try this&lt;BR /&gt;&lt;BR /&gt;send "pids=`/bin/ps aux | grep XXX | awk \'\{ print \$1\}\'`\r"&lt;BR /&gt;send "kill -9 \$pids 2&amp;gt;/dev/null\r";&lt;BR /&gt;&lt;BR /&gt;I have used this in my expect script to kill the remote process.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Vasu&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Oct 2003 06:46:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089070#M806536</guid>
      <dc:creator>Vasudevan MV</dc:creator>
      <dc:date>2003-10-09T06:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089071#M806537</link>
      <description>Thanks Vasu&lt;BR /&gt;&lt;BR /&gt;will please explain your code&lt;BR /&gt;&lt;BR /&gt;send "pids=`/bin/ps aux | grep XXX | awk \'\{ print \$1\}\'`\r"&lt;BR /&gt;send "kill -9 \$pids 2&amp;gt;/dev/null\r";&lt;BR /&gt;&lt;BR /&gt;how can i check whether the would-be -removed process id is right, in other words,&lt;BR /&gt;can i first display with  puts "  "&lt;BR /&gt;that means i need a variable to store the value of send "pids= ....&lt;BR /&gt;and then call puts " the id is $myvariable"&lt;BR /&gt;&lt;BR /&gt;how can be saved the output of send nto varaiable ??&lt;BR /&gt;&lt;BR /&gt;rgds&lt;BR /&gt;&lt;BR /&gt;Thanks all of you guys&lt;BR /&gt;waiting reply&lt;BR /&gt;</description>
      <pubDate>Thu, 09 Oct 2003 07:10:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089071#M806537</guid>
      <dc:creator>CWCW</dc:creator>
      <dc:date>2003-10-09T07:10:36Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089072#M806538</link>
      <description>Basically it greps for XXX process from the output of ps or ps -ef, then picks the 1st field to get the pid of that process on the remote machine and kills it forcibly using -9 option.&lt;BR /&gt;&lt;BR /&gt;Yes, you can display the output of ps or ps -ef on the screen by not storing in a variable:&lt;BR /&gt;&lt;BR /&gt;send "/bin/ps -ef | grep XXX | awk \'\{ print \$1\}\'\r"&lt;BR /&gt; &lt;BR /&gt;In addition to that you can remove 2&amp;gt;/dev/null in the kill command to see the error if it is unable to terminate the process.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Vasu</description>
      <pubDate>Thu, 09 Oct 2003 08:08:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089072#M806538</guid>
      <dc:creator>Vasudevan MV</dc:creator>
      <dc:date>2003-10-09T08:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089073#M806539</link>
      <description>Hi Vasu&lt;BR /&gt;&lt;BR /&gt; this code does not work .&lt;BR /&gt;&lt;BR /&gt;  the comamnd send, sends this line of code.&lt;BR /&gt; &lt;BR /&gt;pids=`/bin/ps aux | grep ftp | awk '{ print $1}&lt;BR /&gt;&lt;BR /&gt;  so only the above line is printed, and&lt;BR /&gt; `/bin/ps aux | grep ftp | awk '{ print $1}&lt;BR /&gt;  is not exucuted at all.&lt;BR /&gt;&lt;BR /&gt;thanks</description>
      <pubDate>Fri, 10 Oct 2003 04:57:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089073#M806539</guid>
      <dc:creator>CWCW</dc:creator>
      <dc:date>2003-10-10T04:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089074#M806540</link>
      <description>hi,experts&lt;BR /&gt;&lt;BR /&gt;I wanted to connect to a remote machine and find out the process of ftp running on the remote machine, in order to kill it.&lt;BR /&gt;Than i have run this expect script&lt;BR /&gt;---------------------------------------&lt;BR /&gt;send {ps aux | grep ftp | awk '{print $2}'}; send "\r"&lt;BR /&gt;expect -re {([0-9]+).*}&lt;BR /&gt;set thepid $expect_out(1,string) &lt;BR /&gt;---------------------------------------&lt;BR /&gt;and i have got this result.&lt;BR /&gt;&lt;BR /&gt;202&lt;BR /&gt;5482&lt;BR /&gt;13215&lt;BR /&gt;&lt;BR /&gt;The middle number (5482) is the process id i am looking for.&lt;BR /&gt;My question is: &lt;BR /&gt;&lt;BR /&gt;1. How can i get only this number and  &lt;BR /&gt;   display it on the screen.&lt;BR /&gt;&lt;BR /&gt;2. How can i save this number on a variable&lt;BR /&gt;&lt;BR /&gt;3. how can i kill this process using this number.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;thanks.</description>
      <pubDate>Fri, 10 Oct 2003 07:25:04 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089074#M806540</guid>
      <dc:creator>CWCW</dc:creator>
      <dc:date>2003-10-10T07:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089075#M806541</link>
      <description>Do you really have to use an expect script?&lt;BR /&gt; &lt;BR /&gt;It would be much easier to use a shell script thus.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;$KILLPID=`remsh 10.10.x.x ps -ef | grep ftp | grep -v grep | awk 'print $2;exit}`&lt;BR /&gt;remsh 10.10.x.x kill $KILLPID</description>
      <pubDate>Fri, 10 Oct 2003 07:50:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089075#M806541</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-10-10T07:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Killing process id</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089076#M806542</link>
      <description>Hi. Guys.&lt;BR /&gt;&lt;BR /&gt;I want to use expect, not shell ( but thanks).&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;this is the code i am using&lt;BR /&gt;---------------------------------------------&lt;BR /&gt;&lt;BR /&gt;send {ps aux | grep ftp | awk '{print $2}'}; send "\r"&lt;BR /&gt;expect -re {([0-9]+).*}&lt;BR /&gt;set thepid $expect_out(1,string) &lt;BR /&gt;---------------------------------------&lt;BR /&gt;and i have got this result.&lt;BR /&gt;202&lt;BR /&gt;5482&lt;BR /&gt;13215&lt;BR /&gt;The middle number (5482) is the process id i am looking for.&lt;BR /&gt;My question is: &lt;BR /&gt;1. How can i get only this number and &lt;BR /&gt;display it on the screen.&lt;BR /&gt;2. How can i save this number on a variable&lt;BR /&gt;3. how can i kill this process using this number.&lt;BR /&gt;thanks.&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Oct 2003 07:04:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/killing-process-id/m-p/3089076#M806542</guid>
      <dc:creator>CWCW</dc:creator>
      <dc:date>2003-10-13T07:04:01Z</dc:date>
    </item>
  </channel>
</rss>

