The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-15-2007
fed.linuxgossip fed.linuxgossip is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 99
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
  #2 (permalink)  
Old 09-15-2007
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
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];
}
Output looks like this:
Code:
#########                                                                [ 14% ]
  #3 (permalink)  
Old 09-18-2007
fed.linuxgossip fed.linuxgossip is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 99
Fine.. how do I integrate that with wget? And how can the script calculate the percentage value from the results of the wget .. instead of a fixed value defined in the script.


Thanks
  #4 (permalink)  
Old 09-18-2007
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
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.
  #5 (permalink)  
Old 09-18-2007
fed.linuxgossip fed.linuxgossip is offline
Registered User
  
 

Join Date: Mar 2007
Posts: 99
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0