batch file or somethng???

Discussion in 'Installation/Configuration' started by PortMan, Jun 15, 2006.

  1. PortMan

    PortMan New Member

    I'm new to Linux. I have several commands that need to be entered one at a time to install packages and get them configured. For example:

    yum install bind-chroot
    hmod 755 /var/named/
    chmod 775 /var/named/chroot/
    chmod 775 /var/named/chroot/var/
    chmod 775 /var/named/chroot/var/named/
    chmod 775 /var/named/chroot/var/run/
    chmod 777 /var/named/chroot/var/run/named/
    cd /var/named/chroot/var/named/
    ln -s ../../ chroot
    chkconfig --levels 235 named on
    /etc/init.d/named start
    In the old DOS world, I could make a batch file that would automatically run these commands. Is it possible to do this in Linux? If so, how? As I stated, I'm new to Linux, so good instructions would be great!!

    Thanks for your help.
  2. PortMan

    PortMan New Member

    I found out how to do a "Shell Script" and made it work. But, now I want to findout how to make an answer of "y" automatically.
    For example, I have a shell script called "myinstall" which has the following:

    yum install mysql mysql-devel mysql-server
    chkconfig --levels 235 mysqld on
    /etc/init.d/mysqld start

    It requires me to type "y" to install the package. Is there a way to make it automatically type "y" and continue without human intervention?

  3. jimjawn

    jimjawn New Member

    Shell Script & Yum


    Yum uses a series of "switches" that you can add to the yum command. You can view this in your terminal by entering yum --usage

    Usage: yum [options] <update | upgrade | install | info | remove | list |
    clean | provides | search | check-update | groupinstall | groupupdate |
    grouplist >

    -c [config file] - specify the config file to use
    -e [error level] - set the error logging level
    -d [debug level] - set the debugging level
    -y answer yes to all questions
    -t be tolerant about errors in package commands
    -R [time in minutes] - set the max amount of time to randomly run in.
    -C run from cache only - do not update the cache
    --installroot=[path] - set the install root (default '/')
    --version - output the version of yum
    -h, --help this screen

    So in order to solve your problem, you would issue the command as:

    yum -y install mysql mysql-devel mysql-server
    chkconfig --levels 235 mysqld on
    /etc/init.d/mysqld start

    that should do it for you. Welcome to linx. Wait till you see some of the scripts out there. It makes batch scripting seem like child's play
  4. PortMan

    PortMan New Member

    Thanks for the respone. I was about to post what I had figured out using:
    yum install mysql mysql-devel mysql-server < y
    making a "y" file with "y" in it. I guess I would have done that wrong :)

    The lost thing I want to do now is to figure out a way to edit a line in a file. For example, to change the httpd.conf file to:

    DirectoryIndex index.html index.htm index.shtml index.cgi index.php index.php3

    I have other files that I want to edit as well (change lines, add, delete).

  5. falko

    falko Super Moderator Howtoforge Staff

    Use a command line editor like vi:
  6. serutan

    serutan New Member

    World's smallest vi tutorial

    Years ago as a VMS programmer I had to use vi to do some work on a Unix machine. Hated it. When I next encountered vi as a Linux newbie I forced myself to learn the minimum required to use it:

    vi filename (start vi)
    shift-i (start insert mode; do this immediately) you can enter text, use Backspace or Delete, arrow keys to move around, Enter key to insert new lines, totally simple.
    esc (stop insert mode, then enter one of the following...)
    :wq (write and quit)
    :q! (just quit, dammit!)

    There's tons more you could learn about vi, and actually it's a very powerful editor, but the above is all you really need to know. Cheers!

Share This Page