[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

bash, perl, C



Hello,
can someone explain to me if it is possible that the functions sleep of C and 
Perl work like the function sleep of bashin this scripts and program:

Bash:

#timerest1.sh
#!/bin/bash 

echo  "The processus will start in 5 seconds"
echo
i=0

for i in `seq 6`; do
echo -ne "\e[0;46;31m $[ 6-$i ]\e[0m"  ;  
sleep 1
echo -en "\r"
done 
echo 

C:

#timerest2.c
#include <stdio.h>
#include <unistd.h>

int main()

{
    unsigned i;

    printf("The processus will start in 5 seconds\n");
   
    for (i = 0; i < 5; i++)

	{
	    printf("\e[0;46;31m%d\e[0m", 5 - i);

	    sleep(1);
	    
	    printf("\r");
	}

    printf("...\n");

    return 0;
}

Perl:

#timeresr3.pl
#!/usr/bin/perl
use strict;
use warnings;

print "The processus will start in 5 seconds\n";
my $i= 0;
print "\n";
while ( $i < 6 ) {
  print "\r";
#  print " "x40;
  print "\e[0;46;31m",5 - $i,"\e[0m  " ;
  sleep 1;
  $i++;
}
print "...\n";

tia
-- 
Gérard 



Reply to: