![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| dialog menu script. please HELP | claudlu | Shell Programming and Scripting | 3 | 05-18-2009 05:06 AM |
| Progress Bar in Perl for UNIX | hifake | Shell Programming and Scripting | 13 | 02-16-2009 05:35 AM |
| Pop up dialog box on remote computers | deaconf19 | Shell Programming and Scripting | 35 | 02-12-2009 02:01 PM |
| html problem: get file name dialog exists? | f33ldead | Shell Programming and Scripting | 0 | 02-25-2008 08:48 PM |
| dialog output | dhinge | UNIX for Dummies Questions & Answers | 2 | 11-30-2006 01:20 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
perl progress bar dialog
Hello,
In perl how to show the percentage download when we download something wget ... For example when we wget some software instead of showing the following ...... ============================================ [root@server]# wget http://www.mirrors.wiretapped.net/se...f-2.7.0.tar.gz --06:31:29-- http://www.mirrors.wiretapped.net/se...f-2.7.0.tar.gz => `iptraf-2.7.0.tar.gz' Resolving Wiretapped - Computer Security Software etc.... 203.220.0.26 Connecting to www.mirrors.wiretapped.net|203.220.0.26|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 363,496 (355K) [application/gzip] 100%[==================================================================================================>] 363,496 136.09K/s 06:31:33 (135.83 KB/s) - `iptraf-2.7.0.tar.gz' saved [363496/363496] ============================================ It will show on right hand side ... 1% of 100% complete and on left hand side it will show ... [360/363496] bytes of download complete Any other suggestions on "perl progress bar dialog" is welcome Thanks |
|
||||
|
This is an example. You need to install Term::ReadKey module from CPAN before you can run it.
Code:
#!/usr/bin/perl -w
$| = 1;
my $steps = 50;
my $columns = &getTerminalSize()->[1];
for (my $i=1; $i<=$steps; $i++) {
my $percent = ($i/$steps*100);
my $pbwidth = $columns-10;
my $numhashes = ($i/$steps*$pbwidth);
printf("\r% -${pbwidth}s% 10s", '#' x $numhashes, "[ " . $percent . "% ]");
sleep 1;
}
sub getTerminalSize {
use Term::ReadKey;
my ($w, $h) = GetTerminalSize(STDOUT);
if (!defined $w || !defined $h) {
die "Cannot determine terminal size!";
}
return [$h, $w];
}
Code:
######### [ 14% ] |
|
||||
|
Why do you have to integrate with wget? Why not just try LWP in perl instead, or WWW::Curl? I cannot think of any good way to do it unless you have access to a WWW library such as curl or LWP, that you can implement whatever status reporting with it.
|
|
||||
|
Hello,
Thank you for your tips... I am zero where it comes to programming.. but I do have the logic/ideas only. I am starting to learn programming. Can you give me a script which shows... downloading for example:- http://www.mirrors.wiretapped.net/se...f-2.7.0.tar.gz and showing the progress bar which uses LWP in perl instead, or WWW::Curl Thanks. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|