分页: 1 / 1

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

发表于 : 2008-04-29 1:30
jeryan
本人想写一个在UBUNTU和FEDORA上面自动下载和安装WINE的脚本,由于刚学SHELL SCRIPT 什么都不懂,无重入手。。。希望各位高手给个例子让小弟从中学习学习。。 :)

发表于 : 2008-04-29 1:37
carbont
好像有这样的帖子的说。

发表于 : 2008-04-29 21:22
jeryan
硬着头皮写了这样一个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!"

发表于 : 2008-04-29 21:44
thword

代码: 全选

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

关于wine的自动安装,记得以前有个叫做easywine的脚本可以参考一下。

发表于 : 2008-04-29 22:10
jeryan
选择菜单是出来了¬¬¬但是结果还有问题,我想是我的条件匹配问题吧?应该怎么改?

---------------------------------------------结果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

发表于 : 2008-04-29 22:23
xiooli
试试:
#!/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