Ubuntu系统编写shell脚本程序一次安装多个软件包

Ubuntu系统编写shell脚本程序一次安装多个软件包


编写shell脚本程序一次安装多个软件,主要用于一些软件依赖环境配置。

1、shell脚本程序必须以下面的行开始(必须方在文件的第一行):

  #!/bin/sh

 

符号#!用来告诉系统它后面的参数是用来执行该文件的程序。在这个例子中我们使用/bin/sh来执行程序。

2、当编辑好脚本后,还必须使其可执行。

使脚本可执行:

  chmod +x filename

3、然后,您可以通过输入: ./filename 来执行您的脚本。


如下:

下面是我安装Oracle11g之前,安装Oracle11g依赖的多个软件包:

1、在vi中编辑如下文件

#!/bin/sh

sudo apt-get install automake -y
sudo apt-get install autotools-dev -y
sudo apt-get install binutils -y
sudo apt-get install bzip2 -y
sudo apt-get install elfutils -y
sudo apt-get install expat -y
sudo apt-get install gawk -y
sudo apt-get install gcc -y
sudo apt-get install gcc-multilib -y
sudo apt-get install g++-multilib -y
sudo apt-get install ia32-libs -y
sudo apt-get install ksh -y
sudo apt-get install less -y
sudo apt-get install lesstif2 -y
sudo apt-get install lesstif2-dev -y
sudo apt-get install lib32z1 -y
sudo apt-get install libaio1 -y
sudo apt-get install libaio-dev -y
sudo apt-get install libc6-dev -y
sudo apt-get install libc6-dev-i386 -y
sudo apt-get install libc6-i386 -y
sudo apt-get install libelf-dev -y
sudo apt-get install libltdl-dev -y
sudo apt-get install libmotif4 -y
sudo apt-get install libodbcinstq4-1 libodbcinstq4-1:i386 -y
sudo apt-get install libpth-dev -y
sudo apt-get install libpthread-stubs0 -y
sudo apt-get install libpthread-stubs0-dev -y
sudo apt-get install libstdc++5 -y
sudo apt-get install lsb-cxx -y
sudo apt-get install make -y
sudo apt-get install openssh-server -y
sudo apt-get install pdksh -y
sudo apt-get install rlwrap -y
sudo apt-get install rpm -y
sudo apt-get install sysstat -y
sudo apt-get install unixodbc -y
sudo apt-get install unixodbc-dev -y
sudo apt-get install unzip -y
sudo apt-get install x11-utils -y
sudo apt-get install zlibc -y

:wq orasetup      #(注释)保存为以orasetup为名字的文件


2、终端中编译: chmod +x orasetup 

3、运行安装,终端中输入: ./orasetup

猜你喜欢

转载自blog.csdn.net/woaiyaou/article/details/78359264