#!/usr/bin/perl

system(clear);
system("rm -f semaphore* request* answer*");

print "Please enter command : ";
$command = <STDIN>;

open(Write,">request");
print Write $command;
close(Write);

system("echo lala > semaphoreB");
system("echo lala > semaphoreA");

$flag=1;

while ($flag) {
    $flag = 0;
    open(Read,"<answer") || {$flag = 1};
}
@answers = <Read>;
close(Read);
$size = @answers;

for($count=0;$count<$size;$count++) {
    print $answers[$count];
}
