python调用so函数_在python中调用.so动态库函数,...-在ubuntu下使用apache cgi运行pytho...-shmdt与shmctl的区别_169IT.COM...

本页文章导读:

▪在python中调用.so动态库函数,获取hashab的计算结果      在网上下载了hashab的动态so库,要计算hashab的结果。这里使用python进行so连接库的调用,并使用calcHashAB 函数得出结果代码如下:

#!/usr/bin/pythonimport cgi, cgitbimport ctypesprint "Content-t.........

▪在ubuntu下使用apache cgi运行python脚本并获取get参数      编辑py文件,如hello.py

#!/usr/bin/pythonimport cgi, cgitbprint "Content-type: text/html\n\n"form = cgi.FieldStorage()name = form.getvalue('name')print name把hello.py放在 /usr/lib/cgi-bin .........

▪shmdt与shmctl的区别      先看看 shmctl()   原型: int shmctl ( int shmqid, int cmd, struct shmid_ds *buf );  返回:成功为 0 ,   失败 为-1 这个特殊的调用和semctl()调用几乎相同,因.........

[1]在python中调用.so动态库函数,获取hashab的计算结果

来源:  发布时间: 2013-11-15

在网上下载了hashab的动态so库,要计算hashab的结果。这里使用python进行so连接库的调用,并使用calcHashAB 函数得出结果

代码如下:

#!/usr/bin/python

import cgi, cgitb

import ctypes

print "Content-type: text/html\n\n"

form = cgi.FieldStorage()

name = form.getvalue('name')

print name

lib_handle = ctypes.CDLL('./libhashab.so')

calcHashAB = lib_handle.calcHashAB

target = "f" * 57

sha1 = "d1baa8ab45a9c34c1446"

uuid = "4ba1aced491cf4dd11bd"

rnd_bytes = "ABCDEFGHIJKLMNOPQRSTUVW"

calcHashAB(target,sha1,uuid,rnd_bytes)

print target

并把它放在cgi下就可以通过web进行访问。

漂漂 2013-01-06 11:49 发表评论

[2]在ubuntu下使用apache cgi运行python脚本并获取get参数

来源:  发布时间: 2013-11-15

编辑py文件,如hello.py

#!/usr/bin/python

import cgi, cgitb

print "Content-type: text/html\n\n"

form = cgi.FieldStorage()

name = form.getvalue('name')

print name

把hello.py放在 /usr/lib/cgi-bin 并赋予可执行的权限 chmod a+x helloworld.py

重启apache2 /etc/init.d/apache2 restart

在浏览器地址栏里输入:http://localhost/cgi-bin/hello.py

qq

参考地址:http://hi.baidu.com/pc_10/item/d5fe7972fbcc8145ee1e53c3

http://www.tutorialspoint.com/python/python_cgi_programming.htm

漂漂 2013-01-06 11:42 发表评论

[3]shmdt与shmctl的区别

来源:  发布时间: 2013-11-15

先看看 shmctl()

原型: int shmctl ( int shmqid, int cmd, struct shmid_ds *buf );

返回:成功为 0 ,   失败 为-1

这个特殊的调用和semctl()调用几乎相同,因此,这里不进行详细的讨论。有效命令的值是:

IPC_STAT :检索一个共享段的shmid_ds结构,把它存到buf参数的地址中。

IPC_SET :对一个共享段来说,从buf 参数中取值设置shmid_ds结构的ipc_perm域的值。

IPC_RMID :把一个段标记为删除

IPC_RMID 命令实际上不从内核删除一个段,而是仅仅把这个段标记为删除,实际的删除发生在最后一个进程离开这个共享段时。

当一个进程不再需要共享内存段时,它将调用shmdt()系统调用卸载,即本进程不再使用这个段,但是,这并不是从内核真正地删除这个段,而是把相关shmid_ds结构的 shm_nattch域的值减1。真正把内核中的共享内存删除还得用shmctl。

鑫龙 2013-01-06 13:08 发表评论

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值