请教高手能帮(指导)我做个这样shell脚本吗?( 100分)

u011139493 2016-07-02 01:07:50
因对linux完全是不怎么窍通,只是知道脚本能办到,因为实验室里有多台主机,我也是借这个机会学一下文件操作的脚本,
yum改升级服务器到本地,也许有其它的方式一个命令行搞定
最主要我是想看如何等待下载完成?

0、下载ftp://192.168.100.100/files.tar.gz到/opt,(这里要等待完成)
1、解压/opt/files.tar.gz 到/opt
2、这里要等待files.tar.gz解压完成,tar.gz比较大
3、删除/etc/yum.conf
4、把/opt/files/yum.conf复制到/etc里面
5、在/home/下面建立samba目录
6、在/opt/建立finish目录
7、chmod 777 finish
8、此时,有/opt/temp/rar,如果是平时安装rar的话,一般进入到/opt/temp/rar,再make来安装的,在shell里,如何安装rar呢?

一个shell,自动完成。。。

...全文
160 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
我是红帽子 2016-07-08
  • 打赏
  • 举报
回复
#!/bin/sh dire=/opt wget -P /opt ftp://192.168.100.100/files.tar.gz -ftp-user=username -ftp-password=passwd if [ $? -eq 0 ];then echo "download file success!" else echo "download file fail!" fi cd $dire tar xcf file.tar.gz && chmod 777 $dire/finish if [ $? -eq 0 ];then echo "unzip file and authorization file successd!" else echo "unzip file and authorization file fail!" fi rm -f /etc/yum.conf && cp $dire/files/yum.conf /etc if [ $? -eq 0 ];then echo "remove yum.conf file and copy yum.conf file success!" else echo "remove yum.conf file and copy yum.conf file fail!" fi mkdir /home/samba $dire/finish if [ $? -eq 0 ];then echo "create samba,finish directory success!" else echo "create samba,finish directory fail!" fi cd $dire/temp/rar ./configure if [ $? -eq 0 ];then echo "configure success!" else echo "configure fail!" fi make && make install if [ $? -eq 0 ];then echo "software install success!" else echo "software install fail!" fi
renwotao2009 2016-07-02
  • 打赏
  • 举报
回复

#!/bin/bash

ftp -n << FTPEND
open 192.168.100.100
user username passwd
binary
cd /
lcd /opt
prompt
get files.tar.gz
close
bye
FTPEND

tar -zxf /opt/files.tar.gz 
rm /etc/yum.conf
cp /opt/files/yum./conf  /etc
mkdir /home/samba
mkdir /opt/finish
chmod 777 /opt/finish

cd /opt/temp/rar
make && make install
没有做执行成功判断,可以参考下

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧