![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
Other UNIX.COM Threads You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| permanent redirection of standard input | gfhgfnhhn | Shell Programming and Scripting | 6 | 11-01-2006 12:52 AM |
| Asking about shell script input output redirection | trivektor | Shell Programming and Scripting | 1 | 10-17-2006 10:13 PM |
| input redirection question | luistid | Shell Programming and Scripting | 0 | 08-22-2006 04:28 AM |
| How to prompt for input & accept input in ONE line | newbie168 | Shell Programming and Scripting | 2 | 09-27-2005 02:02 AM |
| Changing stdin from file redirection to console input | nauman | High Level Programming | 4 | 09-29-2001 05:42 AM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hi everybody, first of all i am a new member in UNIX.com and this is my first post.
I am impressed with the amount of information a person can ever have in this forum, it is really great having something similiar; anyways let me tell you about the problem I am having, hope you will answer me. (P.S: I am new to UNIX, it's been only couple of months I started working on a UNIX machine, so please be patient on me ) I am trying to redirect the input of a executable from a file, i've wrote the required input in that file, but for some reasons the executable isn't taking them in the right order, it is like if it's missing something, and at the end, when the file finish before the input requirement of the program, it start a loop of a character which looks like ~ this one or sometimes .f. the input required is : T [return] 2 1 [return] q q I am putting that in a file let's say called test and starting the command as follows : #command < test am I missing anything ?? |
| Forum Sponsor | ||
|
|
|
|||
|
Thanks Perderabo for your reply, what I am sure about is that i have no clue about what you mean by saying your program seems to require tty input and how that would make a difference, trying to give more information:
the program is a third party application running on AIX, tcsh, it ask user interactively for the options he may need to check. Anyways, I will search for expect now. hope to find what i need :-) thanks again. |
|
||||
|
Quote:
By sending the correct ioctl()'s calls to the standard input (which is assumed to be a tty), the program can set the MIN > 0 and the TIME > 0. (exactly how to do this is documented under "man termio") Once that is done, the program can then issue a multi-char read system call. The editor vi works this way and you can't redirect your input into it either. If The MIN is 1, then a read() will not return until at least one character has been typed. But if TIME is also 1, after a character arrives, the tty driver will wait up to one tenth of a second to see if another character arrives. If it does, a read() of 10 characters would get both characters returned to it. If it didn't, the read() would get just the one character. This is how a program can read a single keystroke. The "A" key will just send the character "A". But the home key will send a mult-character sequence. The program wants to read keystrokes, not characters. But now redirect a file into our program. First the ioctl()'s will now fail. But some programs just ignore the error. Next the multi-byte read() occurs and it gets as many bytes as it specified. In your example you have the characters: 2 1 But there is an implied delay between those keystrokes. The program was depending on that delay. So it gets "21" when it just wanted "2". This is just one way to depend on a tty for input. Read the "man termio" to see everything that the tty driver can offer to the program. |
|
|||
|
your being really very helpful Perderabo, I just remembered one behavior of the program I am running
when it run interactively. the program expect [return] after the first input ("T" in our case) then it ask for (do you want to run in recovery mode [y/n] ) default is no, and [return] is enaugh, after that it doesn't wait for the [return] key after the keystroke, as soon as you press "2" it will go to the corresponding submenu and so on..... I hope i was clear in what i am trying to say. |
|||
| Google UNIX.COM |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|