×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

automating ontape - script

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



 

RE: automating ontape - script

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.

 

RE: automating ontape - script

(OP)
Thank you guys. What is expect?

RE: automating ontape - script

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:

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

in newer Informix versions ontape supports output to files and standard output. Maybe this is an option too.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close