Gary Stainburn wrote: > > Hi all, > > I've got a project where I need to develop an single-board-computer based > network device using packet modems connected to Amateur Radio equipment and > I'm trying to develop a simulator in Perl under Linux and I've got a few > questions. > > Basically I'm going to have X number of nodes running inside Xterm sessions, > all sitting in the same working directory and simulating transmitting data by > appending the data to a file. Each program will simulate receiving the data, > by doing the equivelent of a tail -f on this file. > > Keyboard input will be used to simulate data being received from the box's > serial port. > > 1) How can I simulate the 'tail -f' under perl without hanging my program.
open (F, 'tail -f /var/log/messages |'); while (<F>) { # do stuff } close (F); > > If I pseudo code it it may give a better idea of what I mean. > > // in main code > > if ($command=&getcommand()) { > &do_something($command); > } > > sub getcommand() { > if character available > add character to buffer > if character = end.of.packet > return buffer > else > return false > } > > 2) can this same method be used to get the characters from the keyboard. read 'perldoc perlopentut', go to the part with pipes > 3) can I reduce the priority of these programs (equivelent of the unix 'nice' > command) from within the perl script or do I need to do it from the shell > script calling the program. (If I nice -> xterm -> perl script, will the nice > still affect the perl script or will I have to do xterm -> nice -> perl > script)? open (F, 'nice -15 tail -f /var/log/messages |'); > > 4) Is there an easy way (or a hard way) within Perl to control the xterm > output, something similar to GotoXY that I used to have in TurboPascal in the > good old (?) DOS days. i've never used dos (not even in the good old turbopascal days) but there are term modules: http://www.cpan.org/modules/by-module/Term/ i bet they offer alot of control /Jon > > -- > Gary Stainburn > > This email does not contain private or confidential material as it > may be snooped on by interested government parties for unknown > and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]