Popular recipes by winterTTr Dong http://code.activestate.com/recipes/users/4164498/2008-08-18T20:10:34-07:00ActiveState Code RecipesList System Process and Process Information on win32 (Python) 2008-07-18T02:03:13-07:00winterTTr Donghttp://code.activestate.com/recipes/users/4164498/http://code.activestate.com/recipes/576362-list-system-process-and-process-information-on-win/ <p style="color: grey"> Python recipe 576362 by <a href="/recipes/users/4164498/">winterTTr Dong</a> (<a href="/recipes/tags/sysadmin/">sysadmin</a>). </p> <p>use ctypes , load the win32 API to enum process and list the process info</p> export variable on win32 like *nix (Python) 2008-08-18T20:10:34-07:00winterTTr Donghttp://code.activestate.com/recipes/users/4164498/http://code.activestate.com/recipes/576431-export-variable-on-win32-like-nix/ <p style="color: grey"> Python recipe 576431 by <a href="/recipes/users/4164498/">winterTTr Dong</a> (<a href="/recipes/tags/register_table/">register_table</a>, <a href="/recipes/tags/windows/">windows</a>). Revision 4. </p> <p>Export variable PERMANENTLY on win32 , without needing to reboot system.</p> <p>EXAMPLE:</p> <p>import win32export</p> <p>win32export.export("fooname" , "foovalue")</p> <p>NOTE: </p> <p>you need to install "pywin32" if you want to use this .</p> Exectute shell command on Remote *nix machine (Python) 2008-07-18T02:20:22-07:00winterTTr Donghttp://code.activestate.com/recipes/users/4164498/http://code.activestate.com/recipes/576363-exectute-shell-command-on-remote-nix-machine/ <p style="color: grey"> Python recipe 576363 by <a href="/recipes/users/4164498/">winterTTr Dong</a> (<a href="/recipes/tags/network/">network</a>). </p> <p>Use telnetlib to execute the shell command from localhost.</p> <p>An example to show the funciton. Output the result to result.log.</p> <p>from PyRemoteControl import RemoteShellCommand</p> <h4>host info</h4> <p>host_ip = '192.168.32.72' user_name = 'fw' password = 'fw' result_file = 'result.log'</p> <h4>command List</h4> <p>cmdList = [ 'cd' , 'll' ]</p> <h4>init</h4> <p>cursor = RemoteShellCommand( host_ip , user_name , password , result_file ) cursor.AddPrompt( '[fw@localhost .<em>]\$ ') cursor.AddPrompt( '[root@localhost .</em>]# ' )</p> <h4>connect to Linux</h4> <p>cursor.Login()</p> <h4>change to root</h4> <p>cursor.SendInterActiveCmd( 'su - ' , [ ('Password: ' , 'rootPassord')] , False)</p> <h4>Exec Command</h4> <p>for cmd in cmdList : cursor.SendCmd( cmd )</p> <h4>logout</h4> <p>cursor.Logout()</p>