Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


Search this Thread
Old 04-16-2009, 09:37 AM   #1
LQ Newbie
Registered: Feb 2009
Posts: 8

Rep: Reputation: 0
Automating Interactive script

]I have a script that will install software on all remote host. At the end of the script it starts the part and goes into a interactive mode asking Yes or No questions and prompting to add a username and password. My question is how can I script this so that these questions are answered automatically?

Here is my script.
PGM=`basename $0`

[[ -z $HOSTS ]] && HOSTS="`grep -v \# /opt/local/etc/hosts|grep -i atl380g5test|nawk '{print $1}'`"

echo "$PGM: Installing Sophos AntiVirus Software"
for host in $HOSTS
printf "o PROCESSING HOST: %-20s\n" $host
ping $host 1>/dev/null 2>&1;
if (( $? )) ; then
echo "--Cannot contact host $host";
scp /admin/install.sophos.tar $host:/opt/install.sophos.tar
echo " --installing Sophos Antivirus software on $host"
ssh $host 'cd /opt/ ; tar -xvf install.sophos.tar; /opt/sofos/; rm -r install.sophos.tar
echo " The script will ask you a series of Y or N questions. press enter to start"

The scripts starts the install part then ask a series of questions I want to automate and need assistance with. thanks..

o you accept the licence? Yes(Y)/No(N) [N]

> Y

Where do you want to install Sophos Anti-Virus? [/opt/sophos-av]

> enter

Sophos Anti-Virus GUI is accessible at http://localhost:8081/ from your web browser.

You must now enter a username/password for Sophos Anti-Virus GUI. If you enter a blank password, the Sophos Anti-Virus GUI will be


Username for Sophos Anti-Virus GUI? [admin]


Password for Sophos Anti-Virus GUI?


Re-enter the same password.


Do you want to enable remote management? Yes(Y)/No(N) [Y]


Do you want to enable on-access scanning? Yes(Y)/No(N) [Y]
Old 04-16-2009, 09:50 AM   #2
Registered: Feb 2007
Distribution: RHEL 4, SOLARIS 10
Posts: 91

Rep: Reputation: 15
Try "here documents". I have used them to good effect for things like this, though they don't allways work as intended, so some experimentation may be required.

Try something like.

#!/bin/bash <<LimitString

They work the same way in most unix shells (and perl), but your millage may vary.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH - How to open an interactive script from a non interactive script..... OldGaf Programming 4 06-29-2008 04:34 PM
Automating sftp using a shell script bhandu Linux - Newbie 3 07-17-2007 01:56 AM
automating lynx in a shell script yimboli Programming 15 04-04-2007 02:15 AM
Automating a playlist using shell script... DesiLILO Linux - Newbie 4 04-02-2004 11:03 PM
FTP Script (Automating) noodle123 Linux - General 2 10-16-2002 08:17 AM

All times are GMT -5. The time now is 11:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration