Modifying listener file

Hi Pros,

I'm writing a script to modify listener.ora file on multiple hosts. When I ssh to any server from a central server in our environment we are presented with menu to select the instance. I need to set my environment to listener which could be different number on every instance. How can I do this without having to do any complicated work?

oracle@11204_home> ssh testHost
Last login: Wed Jul 13 15:11:09 2016 from centralHost.whatever
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
        1)   agent12c    @testHost      agent
        2)   listener    @testHost      11.2.0.4
        3)   testdb1     @testHost      11.2.0.4
        4)   testdb02    @testHost      11.2.0
        5)   testdb03    @testHost      11.2.0.4
        6)   testdb04    @testHost      10.2.0

Which instance do you want to use? [1]

So far this is my script and having hard time to set the environment to listener. Also we do not have expect utility installed on any server. The ORATAB file does contain all the homes.

This script is now being developed to test one server only, once this is successful I will add the list of hosts.

#!/usr/bin/ksh
export host="testHost"
echo "HOST= "${host}
ssh -o CheckHostIP=no -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${host} <<EOF
"How do I set my environment to listener always on any host?"
EOF

Any help is appreciated

Is that menu displayed without any further interaction, i.e. you not entering anything? Or do you run a command on the remote host? Is that menu displayed on stdout or on stderr?

Hi Rudi,

That menu is displayed whe I ssh to any host from a dedicated host in our environment. Once the menu is displayed then I have to select the number corresponding to the instance that I would like to connect to.

In my case I always want to connect to the listener which in most cases is represented by number 2 but maybe different on certain hosts. I want to do this via ksh script as provided above.

The main aim here is to modify the listener file by adding a parameter to it on each host and then reload the listener. After that testing connectivity for each instance on that host.

Why didn't you answer all my questions?

Looks like you have kind of "restricted shell" or a dedicated program run at logon. Can you quit that menu without leaving the host?

Sorry about that,

The menu is displayed as soon as you ssh to any host without issuing any command, it is shown on the standard out, if we issue a return key than the default no 1 is selected.

I had developed another script in the past and able to quit that menu by ssh ing as shown in the example script above. The question now is how can I set my environment to listener?

Thanks

You're quite coy with info. I think you'll need to intercept the menu output, read through it until "listener" is found, assign the number to a variable and then reissue the menu, sending the variables contents to select the correct entry.