automating ontape - script
automating ontape - script
(OP)
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
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
RE: automating ontape - script
# 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.
RE: automating ontape - script
Hope This Helps, PH.
FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?
RE: automating ontape - script
RE: automating ontape - script
http://expect.nist.gov
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.
RE: automating ontape - script