Operating System - HP-UX
1751907 Members
4856 Online
108783 Solutions
New Discussion юеВ

Simulate "Enter" Key in script

 
SOLVED
Go to solution
Dick Fischer
Occasional Advisor

Simulate "Enter" Key in script

We use RCS as our program configuration management software in unix. I'm attempting to create a unix script to automate the checkin process of 100+ programs that are modified every time there's a timechange.

Typically one keys text into RCS, and RCS waits for the "Enter" key before going on to the next command. The checkin process does not complete until a period (.) is entered on the final step. The unix script would have a series of RCS commands for each of the 100+ modules. Is there a way of coding the "Enter" key into the script? I've tried a few things, but the script just hangs after the first command.

A typical series of commands would be:

ci -l filename <== checkin and lock filename

??? <== Hit Enter

Time change <== text keyed in explaining what the modification was

??? <== Hit Enter

Changed by yours truly <== second line of text keyed in

??? <== Hit Enter

. <== Period (.) to indicate that I'm done entering text

??? <== Hit Enter

The last "Enter" will indicate that I'm done with the checkin, and RCS will be exited.
9 REPLIES 9
Geoff Wild
Honored Contributor

Re: Simulate "Enter" Key in script

You can do this with an expect script...

http://hpux.ee.ualberta.ca/hppd/hpux/Tcl/expect-5.41/

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Victor Fridyev
Honored Contributor

Re: Simulate "Enter" Key in script

Hi

Try the following:
echo "\n\n\n...\n"| your_script
or this:
your_script<<$$END_OF_INPUT




$$END_OF_INPUT

Each empty string is ENTER

HTH
Entities are not to be multiplied beyond necessity - RTFM
Rodney Hills
Honored Contributor

Re: Simulate "Enter" Key in script

So doing something like-
echo "\n\n\n\n" | ci -l filename

Doesn't work?

Hmmm... Maybe ci reads from STDERR. Try-
echo "\n\n\n\n" | ci -l filename 2<&0

See if that works...

-- Rod Hills
There be dragons...
Dick Fischer
Occasional Advisor

Re: Simulate "Enter" Key in script

The ci -l filename command will execute whether I stick an echo statement in front of it or not.

Beyond that point the process is hanging no matter what variations of echo or END_OF_DATA statements I try.

Rodney Hills
Honored Contributor

Re: Simulate "Enter" Key in script

If "ci" is like "passwd" command, then as stated before, "expect" utility is the best way to drive the input.

-- Rod Hills
There be dragons...
Sundar_7
Honored Contributor

Re: Simulate "Enter" Key in script

I am not sure if I fuly understand your requirement

I will give it a try :-)

ci -l filename <echo "Time Change"
echo "Changed by yours truly"
echo "."
EOF

will this work for you ?
Learn What to do ,How to do and more importantly When to do ?
Tom Danzig
Honored Contributor
Solution

Re: Simulate "Enter" Key in script

I would think that a "here doc" would work in a script:


A typical series of commands would be:


################################
ci -l filename <
text explaining what the mod was
second line of text
.

EOD
################################


The blank lines above should feed in as "Enter" to the ci program.



Dick Fischer
Occasional Advisor

Re: Simulate "Enter" Key in script

The EOD solution did the trick. Thank you all for your suggestions.
Dick Fischer
Occasional Advisor

Re: Simulate "Enter" Key in script

Thread is closed. Thanks again for taking the time to give suggestions.