Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automating ontape - script

Status
Not open for further replies.

amobasse

IS-IT--Management
Sep 10, 2002
19
0
0
US
Hi,
I'm trying to automate ontape and wrote a script to be executed in the crontab. But I am having an issue with my script. Since ontape when invoked it will ask for input like mounting a tape drive "Please mount tape 1 on /infxbu/backup.out and press Return to continue ..." I am sending a null/carriage return thru my script but for some reason is not working. I was wondering if anybody already have a script that I can take a look at or anybody can point out my mistake in the script. Thank you in advance for any help.
Here is the script

host=`hostname`
log=/usr/local/logs/infxontape.log
echo "Starting `hostname` ontape `date`" >> $log
echo "\n"|ontape -s -L 0 >> $log
if [ $? -ne 0 ]
then
echo "ERROR: $hosts did not complete its ontape backup!!!" >> $log
exit 1
else
echo "`hostname` ontape backup created successfully at `date`" >> $log
fi



 
As I recall, you have to redirect input from a file to get ontape to work:

# untested
ontape -s -L 0 < input_file > $log

For a carriage return, I don't think \n will work. You have to use the octal representation \012. To emulate a CR, within input_file, place \012 on a line by itself.

 
You may also use expect.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Expect is a tool for automating interactive applications. While it's available on most Linux systems, you typically have to download it for other systems. Here's the expect home page:


The most common example is automating the passwd command which is impossible from the shell:

#!/usr/local/bin/expect --
# wrapper to make passwd(1) be non-interactive
# username is passed as 1st arg, passwd as 2nd
# Executable only by root
set password [lindex $argv 1]
spawn /usr/bin/passwd [lindex $argv 0]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof
# end script

An excellent book is Exploring Expect by Don Libes.
 
in newer Informix versions ontape supports output to files and standard output. Maybe this is an option too.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top