bash/expect n00b question

Discussion in 'HOWTO-Related Questions' started by ccerino, Mar 7, 2012.

  1. ccerino

    ccerino New Member

    I am trying to write a script that enables me to install agents for Nagios XI on systems.


    Script is like so (pretty simple)

    #!/bin/bash
    ###########################
    # This script is used to install Nagios XI Agents
    # on target systems rather than manually installing
    ############################
    # Move to /tmp for install
    cd /tmp
    #Pickup agent package
    wget http://assets.nagios.com/downloads/nagiosxi/agents/linux-nrpe-agent.tar.gz

    #Untar package
    tar xvfz linux-nrpe-agent.tar.gz

    #Move into agent directory
    cd linux-nrpe-agent

    #Run full install script
    ./fullinstall
    #### IN HERE I NEED THE PROPER EXPECT STATEMENT ######
    ##Install asks if you want to proceed (Do you want to continue? [Y/n])
    ##Then when install is complete "Allow from:" is asked. IP Address(es) of Nagios server(s) goes here
    ### So, two answers are needed

    ##I know THIS cannot be right##

    expect Do you want to continue? [Y/n]
    send Y

    expect Allow from:
    send XXX.XXX.XXX.XXX

    #Restart xinetd service

    /etc/init.d/xinetd restart


    When the agent install is complete ( THIS POINT OF THE SCRIPT ) the IP Address of the Nagios system doing the monitoring needs to be entered. I am sure this is a simple statement that is escaping me. However - I am experiencing a true brain cramp.

    How do I enter the IP address (expect statement?) into this script so it can proceed without manual entry?
     
    Last edited: Mar 7, 2012

Share This Page