ASP --> PERL SCRIPT HELP>>PLEASE>>

Discussion in 'Perl Misc' started by kalusalu, Jul 2, 2003.

  1. kalusalu

    kalusalu Guest

    Hello..I was browsing thru the newsgroups ...and was wondering if anyone
    here can be of assistance to me....as I am very very new to PERL..and have
    this ASP SCRIPT..I have to convert...

    <%
    'Response.Content.Type = "text/plain"
    vpath = Request("vpath")

    IF vpath = "" then
    vpath = "/"
    END IF

    realPath = server.mappath(vpath)

    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder(realPath)

    response.write f.Size & vbcrlf
    response.write.realPath & vbcrlf
    response.write vpath & vbcrlf
    %>

    it outputs the following:
    34342323423 D:\www-roots\www.example.com.80/wwwroot/

    the diskusage the real path the virtual path

    I have written this..

    # $d = det_dir_name();

    $size = 0;
    DIR = opendir $d

    While (readdir DIR) {
    next if /^\.\.?$/ ;
    next if -d$_;
    $size == -s $_;
    }

    print $size
    print $d

    cannot find a function for this det dir name...any ideas..and how I convert
    this ASP SCRIPT ????
     
    kalusalu, Jul 2, 2003
    #1
    1. Advertising

  2. I think this may be more of a webserver question than a perl question.

    Virtual server path sounds vaporish, and very Microsofty (given that you are
    using ASP).

    "kalusalu" <> wrote in message
    news:KrpMa.38291$...
    > Hello..I was browsing thru the newsgroups ...and was wondering if anyone
    > here can be of assistance to me....as I am very very new to PERL..and have
    > this ASP SCRIPT..I have to convert...
    >
    > <%
    > 'Response.Content.Type = "text/plain"
    > vpath = Request("vpath")
    >
    > IF vpath = "" then
    > vpath = "/"
    > END IF
    >
    > realPath = server.mappath(vpath)
    >
    > Set fs = CreateObject("Scripting.FileSystemObject")
    > Set f = fs.GetFolder(realPath)
    >
    > response.write f.Size & vbcrlf
    > response.write.realPath & vbcrlf
    > response.write vpath & vbcrlf
    > %>
    >
    > it outputs the following:
    > 34342323423 D:\www-roots\www.example.com.80/wwwroot/
    >
    > the diskusage the real path the virtual path
    >
    > I have written this..
    >
    > # $d = det_dir_name();
    >
    > $size = 0;
    > DIR = opendir $d
    >
    > While (readdir DIR) {
    > next if /^\.\.?$/ ;
    > next if -d$_;
    > $size == -s $_;
    > }
    >
    > print $size
    > print $d
    >
    > cannot find a function for this det dir name...any ideas..and how I

    convert
    > this ASP SCRIPT ????
    >
    >
     
    Barrett Clark, Jul 8, 2003
    #2
    1. Advertising

  3. kalusalu

    Sara Guest

    "kalusalu" <> wrote in message news:<KrpMa.38291$>...
    > Hello..I was browsing thru the newsgroups ...and was wondering if anyone
    > here can be of assistance to me....as I am very very new to PERL..and have
    > this ASP SCRIPT..I have to convert...
    >
    > <%
    > 'Response.Content.Type = "text/plain"
    > vpath = Request("vpath")
    >
    > IF vpath = "" then
    > vpath = "/"
    > END IF
    >
    > realPath = server.mappath(vpath)
    >
    > Set fs = CreateObject("Scripting.FileSystemObject")
    > Set f = fs.GetFolder(realPath)
    >
    > response.write f.Size & vbcrlf
    > response.write.realPath & vbcrlf
    > response.write vpath & vbcrlf
    > %>
    >
    > it outputs the following:
    > 34342323423 D:\www-roots\www.example.com.80/wwwroot/
    >
    > the diskusage the real path the virtual path
    >
    > I have written this..
    >
    > # $d = det_dir_name();
    >
    > $size = 0;
    > DIR = opendir $d
    >
    > While (readdir DIR) {
    > next if /^\.\.?$/ ;
    > next if -d$_;
    > $size == -s $_;
    > }
    >
    > print $size
    > print $d
    >
    > cannot find a function for this det dir name...any ideas..and how I convert
    > this ASP SCRIPT ????


    Gooday:

    First off try to get your organization off of ASP's- become part of
    the solution not part of the problem. Bill isn't rich enough yet?

    Having said that, a few variations on your idioms you might consider
    (code is typed into the response panel - NOT TESTED!) :


    #!(pathToPerl)/perl -w
    # get used to using -w switch! And look at -T if you're writing CGI

    use strict; # a great switch to use particularly for newbies

    use diagnostics; # optional but gives you some nice wordy messages

    # let's declare our vars
    my $size = 0;

    # let's be helpful to ourselves and signal problems? No?
    # assumes $pathToDir was declared somewhere!
    die "huh? what happened\n$!\n" unless opendir DIR, $pathtoDir;

    # filtered arrays are much nicer to work with!
    @d = grep !/^\.\.?$/, readdir DIR;

    # close up this connection as soon as possible
    closedir DIR;

    # now I assume your trying to SUM the filesizes, ignoring directories?
    # so I'd replace the == in your code with += if that's correct..

    for (@d)
    {next if -d $_;
    $size += -s $_;
    }
    my $f = @d; # number of files
    my $a = $size / $f; #average filesize for fun
    print "total file size for $pathToDir is $size\n$f files, avergage
    size $a\n";
    print "Yes I love Perl- its everything that MS isn not!\n\n";
     
    Sara, Jul 8, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wet Basement
    Replies:
    1
    Views:
    2,536
    BobMonk
    Jul 15, 2003
  2. dpackwood
    Replies:
    3
    Views:
    1,824
  3. KK
    Replies:
    2
    Views:
    624
    Big Brian
    Oct 14, 2003
  4. pj
    Replies:
    3
    Views:
    299
  5. Petterson Mikael

    Execute another perl script from my perl script

    Petterson Mikael, Jan 5, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    142
    Paul Lalli
    Jan 5, 2005
Loading...

Share This Page