Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Script Help

 
Satish Kulkarni
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
There is a install script(install.sh) for installation of our product and I am working on automating the process of installation using ksh script.
But the problem is that the install script does a "more" command on a file and then asks few questions..I do not know how to handle the "more" command.
Any help would be appreciated.

I am pasting a dummy install.sh script and my auto.sh script
-------install.sh------------#!/bin/ksh

DIR=`pwd`
LIC_FILE=$DIR/lic
LOGFILE=$DIR/log

log ()
{
DATE=`date '+%m/%d/%y %H:%M:%S'`
echo "[${DATE}] $1" >> $LOGFILE
}

ifYes ()
{
echo ""
/bin/echo "$* [Yes]: \c"
read ans
case $ans in
""|[yY]*) return 0 ;;
*) return 1 ;;
esac
}

if [ -f $LOGFILE ]; then
rm -rf $LOGFILE
fi

more $LIC_FILE

if ifYes "Are you Testing POP?"
then
log "Good luck for POP ...continue"
else
log "Not POP.Good Day"
fi

if ifYes "Are you testing NetConnect?"
then
log "Good luck for NetConnect..."
else
log "Not NetConnect.Good Day"
fi

------auto.sh---------
#!/bin/ksh

DIR=`pwd`

OUT=$DIR/log

$DIR/install.sh << EOF
Y
Y
EOF
 
Petr Blahos
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what exactly do you mean by 'handle the "more" command'?!?

If you want to automate the script, make it accept a parameter
--silent which when used skips the interactive parts.

P.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have ksh, so I tried (successfull with bash):

It filters out the annoying more, makes the filtered file executable and executes that.

You may stop more interactively with 'q', but that didn't work in the redirection-part.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic