> ps aux

> export UNIX95=1
> ps -ef -o "user,pcpu,cpu,sz"

import subprocess
cmd = 'ls -al'
subprocess.call(cmd,shell=True)


drwxrwxr-x 2 root games       4096 Jun 28 12:45 linux_x86_64
-rw-r--r-- 1 root root        5235 Sep 15 08:02 install.log.syslog
-rw-r--r-- 1 root root       60894 Sep 15 08:02 install.log
-rw------- 1 root root        2285 Sep 15 08:02 anaconda-ks.cfg
drwxr-xr-x 2 root root        4096 Sep 15 08:20 Desktop

import os

cmd = 'ls -al'

os.system(cmd) 


total 1571540
drwxr-x--- 26 root root        4096 Oct  4 01:22 .
drwxr-xr-x 33 root root        4096 Sep 20 01:17 ..
-rw-r--r--  1 root root  1462227520 Sep 17 01:45 ABR11A_ko-KR.exe
-rw-------  1 root root        2285 Sep 15 08:02 anaconda-ks.cfg
-rw-------  1 root root       16332 Sep 27 23:52 .bash_history
-rw-r--r--  1 root root          24 Jul 13  2006 .bash_logout
-rw-r--r--  1 root root         364 Sep 16 02:34 .bash_profile
-rw-r--r--  1 root root        1276 Sep 16 02:33 .bashrc
-rwxr-xr-x  1 root root          40 Oct  4 01:22 cmd.py

>> import py_compile

>> py_compile.compile('test.py')

>> quit

너무 간단한가요??

import socket

socket.gethostbyname(socket.getfqdn())

import commands

ETHER_NAME=0
HEADER=2

result=commands.getoutput('netstat -ni').split('\n')[HEADER:]
ether_name=[]
for line in result:
    ether=line.split()[ETHER_NAME]
    if ether != 'lo':
        ether_name.append(ether)
print ether_name


['eth0', 'eth1']

#!/usr/bin/env python
from socket import *

if __name__ == '__main__':
    target = raw_input('Enter host to scan: ')
    targetIP = gethostbyname(target)
    print 'Starting scan on host ', targetIP

    #scan reserved ports
    for i in range(20, 1025):
        s = socket(AF_INET, SOCK_STREAM)

        result = s.connect_ex((targetIP, i))

        if(result == 0) :
            print 'Port %d: OPEN' % (i,)
        s.close()


~$ ./scanner.py
Enter host to scan: localhost
Starting scan on host  127.0.0.1
Port 22: OPEN
Port 80: OPEN
Port 139: OPEN
Port 445: OPEN
Port 631: OPEN

냉무

from Tkinter import *
import time
def donothing():
   filewin = Toplevel(root)
   button = Button(filewin, text="Do nothing button")
   button.pack()

def input_dev():
   frame_input=Frame(base_frame)
   frame_input.pack(side=TOP)
   lable_input=Label(frame_input,text="input Frame")
   lable_input.pack()

def remove_dev():
   base_frame.destroy()
  
root = Tk()
root.title('JAEHOON NMS')
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Add Device", command=input_dev)
filemenu.add_command(label="Remove Device", command=remove_dev)
filemenu.add_command(label="View all device", command=donothing)
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)

menubar.add_cascade(label="Device", menu=filemenu)

editmenu = Menu(menubar, tearoff=0)
editmenu.add_command(label="Check Ping", command=donothing)
editmenu.add_command(label="Check Cpu/Mem", command=donothing)

menubar.add_cascade(label="Monitor", menu=editmenu)

helpmenu = Menu(menubar, tearoff=0)
helpmenu.add_command(label="Help Index", command=donothing)
helpmenu.add_command(label="About...", command=donothing)

menubar.add_cascade(label="Help", menu=helpmenu)

base_frame=Frame(root, width=500, height=300)
base_frame.pack(fill='both',expand='yes')
base_lable_ip=Label(base_frame, text='IP').grid(row=0,column=0)
base_lable_os=Label(base_frame, text='OS').grid(row=0,column=1)
base_lable_memory=Label(base_frame, text='Memory').grid(row=0,column=2)
ip=Entry(base_frame,text='11.4.14.71')
os=Entry(base_frame)
memory=Entry(base_frame)
ip.grid(row=1,column=0)
os.grid(row=1,column=1)
memory.grid(row=1,column=2)
root.config(menu=menubar)
root.mainloop()

'PYTHON > CODE' 카테고리의 다른 글

[CODE] 현재 사용중인 interface name 가져오기  (0) 2012.09.27
[CODE] Port Scanner 예제  (0) 2012.09.26
[CODE] 시스템 정보 가져오기  (0) 2012.09.24
[CODE] ID/PASSWD 복잡성 체크  (0) 2012.09.24
[CODE] 디스크 사용량 체크  (0) 2012.09.24

+ Recent posts