[问题]如何写自动下载和安装软件的脚本?

sh/bash/dash/ksh/zsh等Shell脚本
回复
jeryan
帖子: 10
注册时间: 2008-02-24 10:09
来自: Northern Ireland

[问题]如何写自动下载和安装软件的脚本?

#1

帖子 jeryan » 2008-04-29 1:30

本人想写一个在UBUNTU和FEDORA上面自动下载和安装WINE的脚本,由于刚学SHELL SCRIPT 什么都不懂,无重入手。。。希望各位高手给个例子让小弟从中学习学习。。 :)
头像
carbont
帖子: 3406
注册时间: 2007-11-22 10:20
来自: 北京

#2

帖子 carbont » 2008-04-29 1:37

好像有这样的帖子的说。
lenovo Thinkpad R60i 0657 LHC
windowsXP……准备换回ubuntu了。

Twitter: @carbont
jeryan
帖子: 10
注册时间: 2008-02-24 10:09
来自: Northern Ireland

#3

帖子 jeryan » 2008-04-29 21:22

硬着头皮写了这样一个SCRIPT,请问有什么地方不对呢?老是显示SELECT NOT FOUND

#!/bin/sh

echo "-------------------------------------------"
echo " | Wine & KeyNote Auto installer for Ubuntu & Fedora | "
echo "-------------------------------------------"

echo "What is your OS?"
select var in "Linux" "Fedora " " Other" ; do
read var
if test" $var" == "1" ;then
wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -
sudo wget http://wine.budgetdedicated.com/apt/sou ... hardy.list -O /etc/apt/sources.list.d/winehq.list
sudo wget http://wine.budgetdedicated.com/apt/sou ... /etch.list -O /etc/apt/sources.list.d/winehq.list
sudo apt-get upgrade
sudo apt-get install wine
sudo wget http://www.tranglos.com/free/files/kntsetup.exe
wine kntsetup.exe
else if test" $var" == "2" ;then
yum upgrade
yum install wine
sudo wget http://www.tranglos.com/free/files/kntsetup.exe
wine kntsetup.exe
else ;then
echo "Sorry these softwares can not be instaled in any other OS temporarily!"
fi
break
done

echo "Congratulation ! Now you can use KeyNote now!"
thword
帖子: 119
注册时间: 2007-04-09 12:19

#4

帖子 thword » 2008-04-29 21:44

代码: 全选

#! /bin/bash
ubuntu下的/bin/sh指向dash,而不是bash,两者语法虽然相差不远,但仍有些区别。

关于wine的自动安装,记得以前有个叫做easywine的脚本可以参考一下。
jeryan
帖子: 10
注册时间: 2008-02-24 10:09
来自: Northern Ireland

#5

帖子 jeryan » 2008-04-29 22:10

选择菜单是出来了¬¬¬但是结果还有问题,我想是我的条件匹配问题吧?应该怎么改?

---------------------------------------------结果1
What is your OS?
1) Linux
2) Fedora
3) Other
#? 1

./test2.sh: line 16: test :找不到命令
./test2.sh: line 24: test :找不到命令
Sorry these softwares can not be instaled in any other OS temporarily!
jeryan@jeryan-laptop:~/桌面$
----------------------------------------------结果2
What is your OS?
1) Linux
2) Fedora
3) Other
#? 2

./test2.sh: line 16: test :找不到命令
./test2.sh: line 24: test :找不到命令
Sorry these softwares can not be instaled in any other OS temporarily!
jeryan@jeryan-laptop:~/桌面$
------------------------------------------结果3

What is your OS?
1) Linux
2) Fedora
3) Other
#? 3

./test2.sh: line 16: test :找不到命令
./test2.sh: line 24: test :找不到命令
Sorry these softwares can not be instaled in any other OS temporarily!
jeryan@jeryan-laptop:~/桌面$

---------------------------------------------


我的脚本:

#!/bin/bash

echo "-------------------------------------------"
echo " | Wine & KeyNote Auto installer for Ubuntu & Fedora | "
echo "-------------------------------------------"

echo "What is your OS?"
select var in "Linux" "Fedora " " Other" ; do
read var
if test" $var" == "1" ;then
wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -
sudo wget http://wine.budgetdedicated.com/apt/sou ... hardy.list -O /etc/apt/sources.list.d/winehq.list
sudo wget http://wine.budgetdedicated.com/apt/sou ... /etch.list -O /etc/apt/sources.list.d/winehq.list
sudo apt-get upgrade
sudo apt-get install wine
sudo wget http://www.tranglos.com/free/files/kntsetup.exe
wine kntsetup.exe
elif test" $var" == "2" ;then
yum upgrade
yum install wine
sudo wget http://www.tranglos.com/free/files/kntsetup.exe
wine kntsetup.exe
else
echo "Sorry these softwares can not be instaled in any other OS temporarily!"
exit
fi

done

echo "Congratulation ! Now you can use KeyNote now!"
exit 0
头像
xiooli
帖子: 6956
注册时间: 2007-11-19 21:51
来自: 成都
联系:

#6

帖子 xiooli » 2008-04-29 22:23

试试:
#!/bin/bash

echo "-------------------------------------------"
echo " | Wine & KeyNote Auto installer for Ubuntu & Fedora | "
echo "-------------------------------------------"

echo "What is your OS?"
echo "1)Linux
2)Fedora
3)Other"
read var
if [ $var==1 ];then
wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -
sudo wget http://wine.budgetdedicated.com/apt/sou ... hardy.list -O /etc/apt/sources.list.d/winehq.list
sudo wget http://wine.budgetdedicated.com/apt/sou ... /etch.list -O /etc/apt/sources.list.d/winehq.list
sudo apt-get upgrade
sudo apt-get install wine
sudo wget http://www.tranglos.com/free/files/kntsetup.exe
wine kntsetup.exe
elif [ $var==2 ];then
yum upgrade
yum install wine
sudo wget http://www.tranglos.com/free/files/kntsetup.exe
wine kntsetup.exe
else
echo "Sorry these softwares can not be instaled in any other OS temporarily!"
exit
fi

echo "Congratulation ! Now you can use KeyNote now!"
exit 0
回复