character I/O basics


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers character I/O basics
# 1  
Old 11-13-2003
character I/O basics

Hello!
I have an application that needs user input.
For testing, I created a text file and redirected it as input for the application.
# test_app < input.txt
This works, but never ends(keeps on getting last char), and it goes too fast.
I would like to create a script that pushes characters "somewhere", at a controlled rate, and then redirect this "somewhere" as input for the app. How do I do this?
TY!
# 2  
Old 11-13-2003
its been a long time since i done this but think this may work in the script.

test_app < input.txt
read $variable

i dont know, you get the idea right?
# 3  
Old 11-14-2003
Not sure I understand entirely, but the following will send your input file through a newly opened file descriptor 3 (ie. "somewhere"), then redirect it into your application at a rate of one line per second....
Code:
while read -u3 LINE
do
   echo $LINE
   sleep 1
done 3< input.txt | test_app

# 4  
Old 11-14-2003
Hi Ygor,
I'll have to dig it a little bit but it does exactly what I need!
One thing though: I'm feeding test_app with characters, so input.txt has 1 char per line. Works good. But once input.txt has been read, test_app keeps on getting the last character. How to avoid that?
And one more question: I thought that "somewhere" could be some kind of virtual device (bridge) that I could use this way:

$ test_app < bridge

and then:
$ echo v > bridge
$ echo f > bridge
And so on, using a script.
Am I dreaming? Smilie

Thanks for your help!
# 5  
Old 11-14-2003
"test_app keeps on getting the last character. How to avoid that?" Fix test_app. It is not detecting detecting end of file.

Is test_app a program that was written to use a tty interface? If so, you should be using "expect".

A fifo will behave more or less like the "bridge" you are describing.

"goes too fast"??? What does that mean??
# 6  
Old 11-14-2003
test_app only uses "cin" for user input. It has not been written to be used with a file at first, I want to use a file to automate user input for testing purposes. It is intented to test the communication with a serial device. It has not been written to use the tty interface. Unfortunately, I don't know what this means.
"Going too fast" means that I want to simulate user input, so I don't want test_app to grab characters from input.txt at a very high rate. Instead, I want to feed it with characters at a fixed rate, say 1 sec.
Hope this helps helping me!
TY!
# 7  
Old 11-14-2003
"It is intented to test the communication with a serial device. It has not been written to use the tty interface. Unfortunately, I don't know what this means."

Those first two sentences probably cannot be true at the same time. And this is probably the crux of your problem. It is probably trying to configure the tty to set baud rate, parity, flow control and stuff like that. The tty driver controls an interface that is indeed serial. And one of the options is how end of file is indicated.

What kind of serial device would the app normally talk to? And where does the user come in? Is the serial device a a terminal with a keyboard?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

help me with basics

hello everyone i have to start with unix as it is a part of my training programme and i have to do a self study, i dont know where to start from. i need some basic questions to be answerd like why we use unix ? what is a terminal? what is an editor? why we write commands inside terminal? these... (4 Replies)
Discussion started by: aryancool
4 Replies

2. Shell Programming and Scripting

ls command basics???

how do i use the ls command with a single argument to list all files whose names end with the letter 'r'? (7 Replies)
Discussion started by: lilbo4231
7 Replies

3. UNIX for Dummies Questions & Answers

awk basics

Hi, Please tell me where can I get started with awk..like the basics and the whole awk stuff. Regards, Deepti (2 Replies)
Discussion started by: gaur.deepti
2 Replies

4. AIX

DB2 basics

Dear friends I am going to study DB2 and i dont have any experience with any DB's.. Please provide me with some links or pdf's for DB2 starters. any advice will be very usefull (2 Replies)
Discussion started by: Vit0_Corleone
2 Replies

5. IP Networking

SAN basics

Hi I like to learn and practice SAN, iSCSI. Could you sugges the appropriate tutorial and small tasks to practice SAN. Thankyou (1 Reply)
Discussion started by: kingskar
1 Replies

6. UNIX for Dummies Questions & Answers

Installation basics

hello, Im new to this Os. so, can i get any information'bout installation basics of unix. (1 Reply)
Discussion started by: Abhijit Bhatt
1 Replies

7. UNIX for Dummies Questions & Answers

Unix Basics

Hey, you said this forum was for Dummies, so don't blame me for the following! :D My whole "web building" life, I've had my sites hosted in one for or another. Lately, I've gotten into PHP and MySQL and, of course, those are also hosted for me. But lately, I've been thinking of using PHP and... (2 Replies)
Discussion started by: cap97
2 Replies
Login or Register to Ask a Question