1833059 Members
2438 Online
110049 Solutions
New Discussion

Automating a script

 
SOLVED
Go to solution
Chris Weislak
Advisor

Automating a script

Hello, I am having some trouble with scripting. I am not well versed in it so I was praying for some help. I am trying to automate archiving for our informix database on an HP-UX 11.0 system. the problem I am having is when I enter the command it needs to have someone hit the enter key once a tape is in. We want it to just start. I have tried 2 suggestions and niether worked they were:

ontape -s -L 0< \n
\n
hit

and the other was (press_enter_here = a return in the script):

ontape -s -L 0 < press_enter_here
hit

I thank you in advance for all your assistance.
14 REPLIES 14
Chris Weislak
Advisor

Re: Automating a script

I also tried:

echo "0\n" |ontape -s -L 0

which did not work.
Ivan Ferreira
Honored Contributor

Re: Automating a script

Try with:

ontape -s -L 0<
hit

The ontape command does not have and option to avoid the prompting for ENTER?

Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Antonio Cardoso_1
Trusted Contributor

Re: Automating a script

using bourne shell or ksh, this would look like

echo "put tape and press enter key"
read rep

Antonio Cardoso_1
Trusted Contributor

Re: Automating a script

have a look at this for more on using shell scripts:
http://docs.hp.com/en/B2355-90046/
A. Clay Stephenson
Acclaimed Contributor

Re: Automating a script

The trick is to simply redirect stdout. When ontape determines that stdout is not a tty device then it does not prompt.


ontape -s -L 0 >> /var/tmp/myontape.log
If it ain't broke, I can fix that.
Chris Weislak
Advisor

Re: Automating a script

I tried the above suggestion and it did not work.
what informix says to try is:

echo "\n" | ontape -s -L 0 | tee -a $LOG

which did not work. there is no switch for ontape that would skip the message.

as for the shell it would be posix I think. I do know it is not Bourne.
Chris Weislak
Advisor

Re: Automating a script

I tried the suggestion to output it to a file. It did not start writing to the tape until I hit enter. So it still needed the return key hit tough all the output went to the file.
This is so weird. Informix says it can be done but I keep trying their suggestions and none seem to work.
Chris Weislak
Advisor

Re: Automating a script

Is it possible to make the script sleep for a few seconds in between starting the command and pressing return. so that maybe the \n could work if applied after a few moments.
Sandman!
Honored Contributor

Re: Automating a script

Hi Chris,

Take a look at expect, which is a tool designed explicitly for automating such tasks...http://expect.nist.gov/

cheers!
Sandman!
Honored Contributor

Re: Automating a script

Here's something I found on Google...

LEVEL=0
echo "$LEVEL

"| ontape -s | head -100 > /tmp/logfile

hope it helps!
Chris Weislak
Advisor

Re: Automating a script

that did enter the proper level but still it prompts for you to press the return key.
It seems that it is looking for that specific key. I typed a bunch of letters and numbers but nothing happened till I pressed the return key.
Sandman!
Honored Contributor
Solution

Re: Automating a script

Chris...forgot to post the URL in my last post; make sure you are including the double quotes and the line-wrap effect in you command. Anyhow take a look at the original

http://www.backupcentral.com/infback.html

cheers!
Victor Fridyev
Honored Contributor

Re: Automating a script

Hi,

You can use the attached script, just update it according to your needs and Informix version.

HTH
Entities are not to be multiplied beyond necessity - RTFM
Chris Weislak
Advisor

Re: Automating a script

This has been very helpful. Thank you all so much for your help.