Operating System - HP-UX
1830061 Members
2606 Online
109998 Solutions
New Discussion

Carriage Return in a script -

 
SOLVED
Go to solution
rmueller58
Valued Contributor

Carriage Return in a script -

All,

I have a question, perhaps one of you can give me an idea of what to do. We are running
Informix 7.3.1UD8 Online Engine,


I have a script I’ve been running manually arch_pei.sh

# cat arch_pei.sh
#!/bin/sh
cd /snapfileserver2
mv level0.pei old.level0.pei
touch level0.pei
chown informix:informix level0.pei
chmod 660 level0.pei
ontape -s -L 0
rm old.level0.pei
#


FWIW the line "ontape -s -L 0" in the script prompts for a mount
Please mount tape 1 on /snapfileserver2/level0.pei

the file and location in question is disk and not tape.


When I run this I am prompted to enter a carriage return at the ONTAPE LINE . How with in this script can I echo or force a carriage return to run this script? Should I use expect?

If any one wth Informix experience sees this they may have a work around.. I'd appreciate it.

Rex Mueller - Educational Service Unit #3
Omaha, NE
13 REPLIES 13
Peter Godron
Honored Contributor

Re: Carriage Return in a script -

James R. Ferguson
Acclaimed Contributor
Solution

Re: Carriage Return in a script -

Hi Rex:

I would try:

# ontape -s -L 0 < /dev/null

Regards!

...JRF...
spex
Honored Contributor

Re: Carriage Return in a script -

Hi Rex,

I'm not familiar with 'ontape', but perhaps this would work:

...
chmod 660 level0.pei
ontape -s -L 0 << _EOF_

_EOF_
rm old.level0.pei
...

PCS
Raj D.
Honored Contributor

Re: Carriage Return in a script -


Omaha,

Check this out:

You can use the below ,Hope this can help,

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


That will provide a carriage retrun after it will ask after doing intital process by ontape ,

Cheers,
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: Carriage Return in a script -


Omaha,

Check this out:

You can use the below ,Hope this can help,

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


That will provide a carriage retrun after it will ask after doing initial process by ontape ,

Cheers,
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: Carriage Return in a script -


Omaha,

Also you can do like this :

# echo "\r" | ./arch_pei.sh

That will add a carriage when it will prompt,


Cheers,
Raj.

" If u think u can , If u think u cannot , - You are always Right . "
rmueller58
Valued Contributor

Re: Carriage Return in a script -

Thanks All, both the
< /dev/null
and the
echo "\r" worked, I didn't try the others.. Appreciate the assist.

I didn't think I'd have to resort to writting an expect script to handle something as simple as a carriage return!

Thanks !!
Raj D.
Honored Contributor

Re: Carriage Return in a script -

Rex , thx for the quick review.
Well , sorry! for the multiple posting happend due to itrc site access problem and due to multiple click,. Hope you understood that.

And nice to know that the script worked.
Enjoy,Cheers,
Raj.


(ps: 0 pts pls)
" If u think u can , If u think u cannot , - You are always Right . "
Peter Godron
Honored Contributor

Re: Carriage Return in a script -

Rex,
could you please confirm that you read the answers provided in the link in my first post ?

Solutions given in that link were:
expect and/or redirct of input (use of <<)
rmueller58
Valued Contributor

Re: Carriage Return in a script -

Peter,

Yes, I did read the other thread.. I've been using Expect for many other things.. However for this "issue" I felt it was not merited to use it at this point.
I do keep references to refer back to when I script. My brain doesn't always recall things like it used to 10 years ago. :D
Peter Godron
Honored Contributor

Re: Carriage Return in a script -

Rex,
did you also read on in that link and see Steve Lewis's solution - which was the use of << EOF

Rather than just answering a particular problem with a one-liner I try to find a previous thread which suggests a number of solutions, as users tend to have preferences.

In this case, the use of << was one answer (as also offered by Spex). You mentioned expect as a possible solution in your description.



rmueller58
Valued Contributor

Re: Carriage Return in a script -

Yes, <
Thank you.
rmueller58
Valued Contributor

Re: Carriage Return in a script -

Thanks All.