FAQ
Hi,
my ( $rc2, $backupsizetrans ) =
rexec(
$backuphost,
'du -k '
. "$backupdir\/$backdir2"
. ' |tail -1 |awk \'{ print $1 }\''
);

to get the size of a certain directory from another machine. In my test
case, this results to 72KB.
This is still unsolved ...
What's even more interesting, the du (Filesys::DiskUsage) says the
directory has a local size of 69539 Bytes which, divided by 1024,
results to 67.9091... .
... but I found the solution for this one: There is an option for the
Filesys::DiskUsage to round up the file sizes to the next block, which
is DISABLED by default - that's why I got different file sizes.

Unfortunately, this does not explain the difference between the local du
and the one via rexec on a remote machine. Any help appreciated.

Cheers,
Nora

Search Discussions

  • Thomas Bätzler at May 5, 2010 at 6:56 am

    HACKER Nora asked:
    Unfortunately, this does not explain the difference between the local
    du and the one via rexec on a remote machine. Any help appreciated.
    When you're getting different results then you're doing something differently ;-)

    For one thing, you're using just "du" to call the binary, so we can't be sure you're calling the same "du" in each case. So, when logged in on the remote machine, do "which du" and use the resulting fully qualified path in your rexec call.

    Also, look at your environment ("set" and "alias") on the remote machine to see wether you're getting additional options that way.

    MfG,
    Thomas Bätzler
    --
    BRINGE Informationstechnik GmbH
    Zur Seeplatte 12
    D-76228 Karlsruhe
    Germany

    Fon: +49 721 94246-0
    Fon: +49 171 5438457
    Fax: +49 721 94246-66
    Web: http://www.bringe.de/

    Geschäftsführer: Dipl.-Ing. (FH) Martin Bringe
    Ust.Id: DE812936645, HRB 108943 Mannheim
  • HACKER Nora at May 5, 2010 at 8:42 am
    Hi Thomas,
    For one thing, you're using just "du" to call the binary, so we can't
    be sure you're calling the same "du" in each case. So, when logged in
    on the remote machine, do "which du" and use the resulting fully
    qualified path in your rexec call.
    Check, this is ok - locally an remotely /usr/bin/du is used.
    Also, look at your environment ("set" and "alias") on the remote
    machine to see wether you're getting additional options that way.
    I don't think I will find the answer there - because it's getting even more strange: I copied the questionable code to a separate file, for testing purposes. Funnily, it worked just as expected:

    #!/usr/bin/perl -w
    use strict;
    use warnings;
    use Filesys::DiskUsage qw/du/;

    my $backuphost="hsr3s1p7";
    my $backupdir="/backup";
    my $localdir="/opt/app/oracle/oradata4/dumps";
    my $backdir="MVSTADB_9.9.99.99_100505-085707";

    my $backdir_used = du( { 'sector-size'=>512 }, "$localdir\/$backdir" ); # zum Berechnen
    chomp($backdir_used);
    my $backdir_used_kb = $backdir_used/1024; # zur schönen Ausgabe
    print "needed space: $backdir_used_kb KB\n";

    my ( $rc2, $backupsizetrans ) =
    rexec(
    $backuphost,
    '$(which du) -k ' # KB, zum Berechnen
    . "$backupdir\/$backdir"
    . ' |tail -1 |awk \'{ print $1 }\''
    );
    chomp($backupsizetrans);
    print "Backup size after ftp: $backupsizetrans KB\n";

    gives me exactly the same:

    oracle:/opt/data/magna/wartung/work/nora>./test.pl
    needed space: 68 KB
    Backup size after ftp: 68 KB

    I am executing both scripts with the same user (oracle) in the same environment on the same machine. I even closed the editor, closed all open terminal sessions to the machine, re-opened them and immediately executed the scripts. Of course, copying the (working) syntax from the extract script back into the original source didn't have any effect, no correct result yet.

    Really confused now ...

    Nora

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedMay 5, '10 at 6:44a
activeMay 5, '10 at 8:42a
posts3
users2
websiteperl.org

2 users in discussion

HACKER Nora: 2 posts Thomas Bätzler: 1 post

People

Translate

site design / logo © 2023 Grokbase