分类:
2006-06-16 16:02:15
#!/bin/sh
#
# This script will copy the libraries
when a process run.
# Author: Wangyao
# E-mail: wangyao@cs.hit.edu.cn
#
Name=$1
Store_Dir=$2
#Judge the $Store_Dir exist or not
if [ ! -z $Store_Dir ];then
mkdir -p $Store_Dir
fi
lsof -c $Name | awk '{print $9}'|grep
'lib' > lsof_lib_file
# Judge the process exist or not
if [ ! $? ];then
echo "The process dones't exist!"
exit
fi
for file in $(cat lsof_lib_file)
do
# if the $Store_Dir and $file have
two //,substitute to /
Dir=$(echo $Store_Dir$(dirname $file) | sed
's/\/\//\//')
if [ ! -z $Dir ];then
# mkdir $Dir is wrong
mkdir -p $Dir
fi
cp -a $file $Dir
done |