<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v = 
"urn:schemas-microsoft-com:vml" xmlns:o = 
"urn:schemas-microsoft-com:office:office" xmlns:w = 
"urn:schemas-microsoft-com:office:word" xmlns:m = 
"http://schemas.microsoft.com/office/2004/12/omml"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.3132" name=GENERATOR>
<STYLE>@font-face {
        font-family: Cambria Math;
}
@font-face {
        font-family: Calibri;
}
@font-face {
        font-family: Tahoma;
}
@page Section1 {size: 612.0pt 792.0pt; margin: 72.0pt 72.0pt 72.0pt 72.0pt; }
P.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
LI.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
DIV.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0cm 0cm 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.EmailStyle17 {
        COLOR: windowtext; FONT-FAMILY: "Calibri","sans-serif"; mso-style-type: personal
}
SPAN.EmailStyle18 {
        COLOR: #1f497d; FONT-FAMILY: "Calibri","sans-serif"; mso-style-type: personal-reply
}
.MsoChpDefault {
        FONT-SIZE: 10pt; mso-style-type: export-only
}
DIV.Section1 {
        page: Section1
}
</STYLE>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=EN-GB vLink=purple link=blue>
<DIV dir=ltr align=left><SPAN class=072524711-24092007><FONT face=Arial 
color=#0000ff size=2>Always be careful with int() incase any of the values have 
a leading zero - check the documentation for int() 
carefully.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=072524711-24092007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=072524711-24092007><FONT face=Arial 
color=#0000ff size=2>Cheers,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=072524711-24092007><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=072524711-24092007><FONT face=Arial 
color=#0000ff size=2>Tim Delaney</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> 
python-list-bounces+tdelaney=avaya.com@python.org 
[mailto:python-list-bounces+tdelaney=avaya.com@python.org] <B>On Behalf Of 
</B>Robert Rawlins - Think Blue<BR><B>Sent:</B> Monday, 24 September 2007 5:10 
PM<BR><B>To:</B> 'Robert Rawlins - Think Blue'; 
python-list@python.org<BR><B>Subject:</B> RE: Almost There - 
os.kill()<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV class=Section1>
<P class=MsoNormal><SPAN style="COLOR: #1f497d">Woops,<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: #1f497d"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: #1f497d">Spoke too soon, just wrapped 
them in int() and it works a charm :-D<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: #1f497d"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: #1f497d">Rob<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN style="COLOR: #1f497d"><o:p> </o:p></SPAN></P>
<DIV>
<DIV 
style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0cm; BORDER-TOP: #b5c4df 1pt solid; PADDING-LEFT: 0cm; PADDING-BOTTOM: 0cm; BORDER-LEFT: medium none; PADDING-TOP: 3pt; BORDER-BOTTOM: medium none">
<P class=MsoNormal><B><SPAN lang=EN-US 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">From:</SPAN></B><SPAN 
lang=EN-US style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'"> 
python-list-bounces+robert.rawlins=thinkbluemedia.co.uk@python.org 
[mailto:python-list-bounces+robert.rawlins=thinkbluemedia.co.uk@python.org] 
<B>On Behalf Of </B>Robert Rawlins - Think Blue<BR><B>Sent:</B> 24 September 
2007 12:23<BR><B>To:</B> python-list@python.org<BR><B>Subject:</B> Almost There 
- os.kill()<o:p></o:p></SPAN></P></DIV></DIV>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>Hello Guys,<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>Finally got around to sitting down to tidy up this script 
this morning but I’m having a small syntax problem with os.kill() to kill a 
process on my system. Here is the code:<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal><SPAN style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">def 
killApplication():<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">       
pid = file('/var/lock/MyApplication.lock').read().strip()<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">       
<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">       
logging.info('Killing Application Process: %s' % pid)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">       
os.kill(pid, 15)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">       
logging.info('Application %s Killed' % pid)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal>As you can see if rips the PID from the lock file, which 
works fine as I get log data which says ‘Killing Application Process: 3079’ 
exactly as I would expect it too. However when I run this script I get the 
following error:<o:p></o:p></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'"><o:p> </o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">Traceback (most recent call 
last):<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">  File 
"/pblue/new/Alive.py", line 50, in ?<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">    
main()<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">  File 
"/pblue/new/Alive.py", line 47, in main<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">    
doCheck()<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">  File 
"/pblue/new/Alive.py", line 43, in doCheck<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">    
killApplication()<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">  File 
"/pblue/new/Alive.py", line 28, in killApplication<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">    
os.kill(pid, 15)<o:p></o:p></SPAN></P>
<P class=MsoNormal><SPAN 
style="FONT-SIZE: 9pt; FONT-FAMILY: 'Courier New'">TypeError: an integer is 
required<o:p></o:p></SPAN></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>Which would suggest its passing those arguments in as the 
wrong data types to the kill command. What is the best way to convert 
these?<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>Thanks guys,<o:p></o:p></P>
<P class=MsoNormal><o:p> </o:p></P>
<P class=MsoNormal>Rob<o:p></o:p></P></DIV></BODY></HTML>