期末Linux课程设计(2)—.exam_init部分
原创
©著作权归作者所有:来自51CTO博客作者axxbout的原创作品,请联系作者获取转载授权,否则将追究法律责任
//默认是/root/060607233目录
#!/bin/bash
stunum=$(basename $(pwd)) //返回一个字符串参数的基本文件名称
set $(echo $stunum|cut -c 8-9) //从文件提取考生的座号
net=$1
set $(echo $stunum|cut -c 7) //从文件提取考生的班级号
ip=$1
#echo "Student number is $net Class number is $ip"
#echo $net $ip
ifconfig | head -2 > temp //从ifconfig取得前两行
if grep "eth0" temp >& /dev/null && grep "inet addr" temp >& /dev/null
then
set $(tail -1 temp|cut -d : -f 2)
oldipaddr=$1
rm -rf temp
ifconfig eth0 192.168.$net.$ip$ip >/dev/null //linux的ip
ping -c 2 192.168.$net.$ip >/dev/null
if [[ $? == 0 ]] //ping的返回值
then
cp /var/exam/.netrc.exam_init /root/.netrc
ftp 192.168.$net.$ip &> /dev/null
ifconfig eth0 $oldipaddr
else
printf "\tWindows XP System IP address must be 192.168.$net.$ip\n" //win的ip
sleep 5
exit 3
fi
else
rm -rf temp
ifconfig eth0 192.168.$net.$ip$ip >/dev/null
ping -c 2 192.168.$net.$ip >/dev/null
if [[ $? == 0 ]]
then
cp /var/exam/.netrc.exam_init /root/.netrc
ftp 192.168.$net.$ip &> /dev/null
ifconfig eth0 $oldipaddr
else
printf "\tWindows XP System IP address must be 192.168.$net.$ip\n"
sleep 5
exit 3
fi
fi
rm -rf /root/.netrc
if [[ -d /var/exam/studnet ]]
then
rm -rf /var/exam/student
fi
mkdir /var/exam/student
cp /var/exam/.handin /var/exam/student/Handin
#tar xvf exam.tar 1>/dev/null
tar xvf exam.tar >&/dev/null
cp -f handin.conf /var/exam/student/handin.conf
rm -rf exam.tar
rm -rf handin.conf
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Beginctf 2024 pwn部分题解
beginctf 2024 pwn 部分题解wp
格式化字符串 beginctf pwn 栈溢出 wp -
课程设计(C语言)部分讲解
课程设计(C语言版)部分讲解重点设计及编码以下是我从整体代码中节选的登录代码该代码可以独立运行,
课程设计 while循环 数组 #include