Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incorporate Ctrl-Z into program

Status
Not open for further replies.

chuair

Programmer
Apr 9, 2001
20
SG
I have a program with a set of predefined command that I will enter. A so called editor will apprear next that requires me to enter some text and then I am required to press Ctrl-Z to save and end the program. How do I incorporate the Ctrl-Z into my program so that I don't have to do it manually?
 
Something like this ?
echo "\032\c"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the prompt reply. The problem now is that after executing the command of my program by script, it sort of like hangs there, waiting for the text to be entered and the Ctrl-Z to be entered. How do I programmatically do it?
 
As you said nothing about your script code, just a guess:
echo "\
line1 of text
line2 of text
\032\c" | yourProgram

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Sorry. The command for my program is like
exex -c "ZC:11:1:4:1,DEM:4;" -n MC_C_11 which is executed in UNIX environment. It will then go to something like vi mode where I will key in some text and press Ctrl-Z to save and exit the program, which will bring me back to the UNIX Shell prompt.
 
Have you tried something like this ?
echo "\
line1 of text
line2 of text
\032\c" | exex -c "ZC:11:1:4:1,DEM:4;" -n MC_C_11

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Doesn't seems to work leh.It will just hangs there and the cursor keeps blinking.....
 
Seems the exex program reads /dev/tty instead of the standard input.
You may try using expect.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Expect?What's that?How do I do it? And is the /c the equivalent of Ctrl-Z?
 
Have you thought about using a different editor or possibly not using an editor at all?
 
Hahahahahahahahaha....................Nope. We are trying to implement something into the system and it's one of the requirements that we have to go through.............I guess if there's no other way, then I just have to do it manually, keying in one by one..... :-(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top