#!/bin/bash ### rundots() { ( trap 'exit 0' SIGUSR1; while : ; do echo -ne '.' >&2; sleep 0.2; done) & dotpid=$!; } ### stopdots() { kill -USR1 $dotpid; wait $dotpid; trap EXIT; } ### startdots() { echo -e "\nExecuting function >>>> $(tr [a-z] [A-Z] <<< "${FUNCNAME[ 1 ]}") <<<<<" echo -ne "---->>Script executing, please wait" rundots; trap "stopdots" EXIT; return 0; sleep 0.3} ### main1() { startdots echo -e "display space usage" > /tmp/shell_script.log sleep 4 du -sh * >> /tmp/shell_script.log stopdots } main2() { startdots echo -e "list files," >> /tmp/shell_script.log sleep 4 ls -lsrt >> /tmp/shell_script.log stopdots echo -e "\n\n*********** END OF THE BASH SCRIPT ************" } ### call functions main1 main2 #### #!/usr/bin/perl -w $|=1; use CGI qw(:standard); #use IO::Handle; use FileHandle; print "Content-type: text/html\n\n"; print ' Page title '; open (my $cmds, "/var/www/cgi-bin/shell_script.sh |"); open (my $LOG, '>', '/tmp/perl.log'); select((select($LOG), $|=1)[0]); while (<$cmds>) { #print "
";
        print;
        print $LOG $_;
#print "
"; } close $cmds; close $LOG; print ' ';