linux api笔记(1):判断文件是否存在
如果在linux C\C++环境下判断某个文件是否存在,可以使用access函数:
#include <unistd.h>
#include <stdio.h>
int main()
{
const char* file1 = "access.cpp";
const char* file2 = "access1.cpp";
printf("%s:%d\n", file1, access(file1, F_OK));
printf("%s:%d\n", file2, access(file2, F_OK));
return 0;
}
假设文件access.cpp且access1.cpp不存在,那么结果为:
access.cpp:0
access1.cpp:-1
相关文档:
linux下的主要文件
/boot/grub/grub.conf GRUB configuration file
/boot/module-info-* Module information for the Linux kernel
/boot/System.map-* Map of the Linux kernel
/boot/vmlinuz-* Linux kernel
/etc/aliases Mail aliases
/etc/a ......
下面是俺写的测试脚本,为了能运行多次测试程序性能,想控制运行个数,通过lockfile 和 grep配合进行限制。
#!/bin/bash
. /etc/profile
project=simnin
export CLASSPATH=.:/usr/$project:$CLASSPATH
for jarfile in /usr/$project/lib/*.jar ; do
if ! echo $CLASSPATH | grep $jarfile > /dev/null
then
&nbs ......
################## 修改防火墙端口 #################
当Linux打开防火墙后,你会发现,从本机登录23端口是没有问题的,但是如果从另一台pc登录该linux系统后,你会发现提示这样的错误:
不能打开到主机的连接, 在端口 23: 连接失败
查看端口情况:service iptables status
因为linux防火墙默认是关闭23端口的 ......
linux下apache+php安装常见问题
configure: error: Unable to find libgd.(a|so)
如果使用的是ubuntu或debian就很简单了,直接sudo apt-get install apache2 libapache2-mod-php5 php5 php5-gd 就基本上搞定,但是用源代码安装还是很麻烦~
wget http://www.boutell.com/gd/http/gd-2.0.11.tar.gz
tar zxvf gd-2.0.11 ......