[Tutor] Question about stdin/stdout

Bob Heasman bobhe at telkomsa.net
Thu May 27 15:36:24 EDT 2004


I have just started programming with Python using the book and disk 
supplied by Michael Dawson, and am rather overawed at the questions and 
answers that I have seen.

I am a Radio Amateur and I have a need for a program that will, when the 
program sees one of a few call signs, it will send an instruction to the 
parallel port to make one of the pins go high. I will have a series of 
relays which will operate and rotate my beam towards that particular 

Now I have devised a means of getting the "password" program to 
recognise the following line and activate the appropriate command, as 

#! /usr/bin/python
# Password
# Demonstrates the if structure
# Antenna direction changer
# Bob Heasman 25/04/04
print "\tWelcome to System Security Inc."
print "_where security is our middle name"

password = raw_input("\n\nEnter your password: ")

if password == "[PTCPACTOR - 19 - UA6ADV-0]":
     print "Activate pin 1"


if password == "F3KT":
     print "Activate pin 2"

raw_input ("\n\nPress the Enter key to exit.")

This works well as far as it goes, but it is reliant on having stdin and 
stdout being the keyboard and the screen. I have read through the book 
and see that he goes on to demonstrate how to write games which rely on 
exactly the same stdin/stdout.

I realise that "Activate pin 1" won't work, but I can sort that out. I 
just want to know about stdin/stdout.

What I want to do is get the program to read a screen display (or I can 
get Linux to save this display to a file using the "tail -f" command) or 
file, and when it recognises the line with the call sign "UA6ADV" (or 
one of the other call signs) it will then send a cmd to the parallel 
port, ttyS0, to make one of the pins go high.

So this uses a file as "stdin", and "stdout" is a pin on the parallel 
port.Can someone give me some pointers as to how to do this, or if 
necessary, point me to a book or a web site where I can find this info.

I suppose I could wade through the book in the hope that I find 
something to do this, but I really would like to get this program 
working asap, and going through the book will take me forever.

I have been a bit verbose I am afraid, but I thought rather do that then 
  be confusing by leaving out info.


More information about the Tutor mailing list