[Python]代码 import subprocess import re keydic = {"MemTotal":"总内存(单位G)", "MemFree":"剩余内存(单位G)", "MemAvailable":"可用内存(单位G)", "Cached":"缓存内存(单位G)"} def command(command): p = subprocess.Popen(command, she
#!/usr/bin/python ''' ''' import gtk.gdk import gtk import glib class MyRect(): def __init__(self, x = 0, y = 0, w = 0, h = 0): self.x = x self.y = y self.w = w self.h = h def __init__(self, x, y): se
Linux下openssl提供了一系列哈希及加密的函数,如果调用openssl提供的MD5函数生成任意字符串的MD5呢?下面提供了一段代码实现Linux下c字符串生成md5的函数。 具体代码: #include
用java实现linux上exe文件的版本号读取功能。下面是详细代码: package com.herman.utils; import java.io.File; import java.io.Fi
php将linux运行时间转换成更好看的格式
FileProtocolHandler " + url); } else { // Unix or Linux String[] browsers = { "firefox", "opera", "konqueror"
conv -f file1 -f file2 有了这个转换编码,把Windows下的工程引入到Linux上开发就轻松得多了,不再有什么字符编码读不出来的问题; 来自:http://blog.csdn
Linux环境下C语言实现贪吃蛇游戏 [liul@test snake]$ more snake.c #include
python获得linux服务器的内存使用率,虚拟内存使用率. linux系统的内存占用信息在/proc/meminfo文件中。 您可以打开这个文件会看到更多详细的信息。 def get_mem_usage_percent():
#include <sys/ioctl.h> #include <net/if.h> #include <unistd.h> #include <netinet/in.h> #include <string.h> int main() { struct ifreq ifr; struct ifconf ifc; char buf[2048]; int success = 0; int sock =
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <unistd.h> #include <fcntl.h> #include <sys/types.h> int main(int argc, char *argv[]) { char *buf = NULL; int fd_
<?php $exec = shell_exec('uptime'); $uptime = explode(' up ', $exec); $uptime = explode(',', $uptime[1]); if (strpos($uptime[0], 'day')) { $time = explode(':', $uptime[1]); echo('Current system uptime
发送端源码: // 发送端 #include <iostream> #include <stdio.h> #include <sys/socket.h> #include <unistd.h> #include <sys/types.h> #include <netdb.h> #include <netinet/in.h> #include <arpa/inet.h
import socket import fcntl import struct def get_ip_address(ifname): """ >>> get_ip_address('lo') '127.0.0.1' >>> get_ip_address('eth0') '38.113.228.130' """ s = socket.socket(socket.AF_INET, socket.S
定制板卡中bash无法使用,使用标准sh完成对系统及业务监控 #! /bin/sh #Process_Name="/guard /aps /sa /zyguard" Process_Name="/mp /mcu" #获取主机IP地址 ip=`ifconfig eth0 |grep "inet addr"| cut -f 2 -d ":"|cut -f 1 -d " "` gstr="/guard"
这段代码可以监控当前目录及子目录文件的创建,修改,删除等变化,需要用到pyinotify模块,pyinotify模块可以到: http://pyinotify.sourceforge.net/ 下载 #!/usr/bin/env python #coding=utf-8 import os from pyinotify import WatchManager, Notifier, ProcessE
这篇虽然是C++ 的语句,但因为只是练习,图方便就用C风格的方式写了 #include <mysql/mysql.h> #include <iostream> #include <string> #include <cstdlib> int main() { MYSQL *connection; MYSQL_RES *result; MYSQL_ROW row; connection = mysq
#!/bin/bash PATH="$PATH:/usr/local/bin:/usr/bin" RUBY_VERSION="2.2.3" RUBY_NAME="ruby-$RUBY_VERSION" RUBY_FILE_TAR="$RUBY_NAME.tar.gz" SOFT_DIR="/opt/soft" INSTALL_DIR="/opt/ops/Frigga" HTTP_CONF="con
1. 最简单的方法: mail -s text **@mail.ustc.edu.cn 这条命令的结果是发一封标题为text的空信给后面的邮箱,但是往往这类邮件会被当成垃圾邮件来处理, 所以如果没有收到邮件,建议打开垃圾箱来查看一下.第一种方法,你可以把当前shell当成编辑器来用, 编辑完内容后Ctrl-D结束。 2,实用的mail发送方法。 #第二种方法,使用管道命令 echo “This i
#!/bin/bash # Name:bakmysql.sh # This is a ShellScript For Auto DB Backup and Delete old Backup #备份地址 backupdir=/home/mysqlbackup #备份文件后缀时间 time=_` date +%Y_%m_%d_%H_%M_%S ` #需要备份的数据库名称 db_name=test #