Net::SFTP::Attributes

Net::SFTP::Attributes

am 23.10.2006 17:56:52 von bmaynard

Does anyone know how to handle a Net::SFTP::Attributes object? An
example would be awesome if anyone can provide?

Thanks

Ben

Re: Net::SFTP::Attributes

am 23.10.2006 19:10:08 von Paul Lalli

bmaynard@geekserv.com wrote:
> Does anyone know how to handle a Net::SFTP::Attributes object? An
> example would be awesome if anyone can provide?

What was wrong with the descriptions and example you found when you
looked up the documentation to the module?

http://search.cpan.org/~dbrobins/Net-SFTP-0.10/lib/Net/SFTP/ Attributes.pm

Paul Lalli

Re: Net::SFTP::Attributes

am 23.10.2006 19:23:30 von bmaynard

The information in the documentation is very terse, and really doesn't
give a good description on how to handle the data or at least a
description on what format it is stored in.


Paul Lalli wrote:
> bmaynard@geekserv.com wrote:
> > Does anyone know how to handle a Net::SFTP::Attributes object? An
> > example would be awesome if anyone can provide?
>
> What was wrong with the descriptions and example you found when you
> looked up the documentation to the module?
>
> http://search.cpan.org/~dbrobins/Net-SFTP-0.10/lib/Net/SFTP/ Attributes.pm
>
> Paul Lalli

Re: Net::SFTP::Attributes

am 23.10.2006 20:53:45 von Paul Lalli

bmaynard@geekserv.com wrote:
> Paul Lalli wrote:
> > bmaynard@geekserv.com wrote:
> > > Does anyone know how to handle a Net::SFTP::Attributes object? An
> > > example would be awesome if anyone can provide?
> >
> > What was wrong with the descriptions and example you found when you
> > looked up the documentation to the module?
> >
> > http://search.cpan.org/~dbrobins/Net-SFTP-0.10/lib/Net/SFTP/ Attributes.pm
> The information in the documentation is very terse, and really doesn't
> give a good description on how to handle the data or at least a
> description on what format it is stored in.

I don't at all understand what you're getting at. The documentation is
"terse" because there's very little to say about it. There's nothing
complicated. The size() method returns the size (a number of bytes).
The atime() method returns the last access time of the file (a number,
I'm sure. Presumably seconds since the epoch, like stat() itself
returns. A simple printing of that value would confirm it.

Can you be any more specific about what parts you don't understand?
You've twice now used the term "handle", which has no meaning in this
realm. What do you want to do with the data, and how are you being
prevented from doing it?

Paul Lalli

Re: Net::SFTP::Attributes

am 23.10.2006 21:20:45 von bmaynard

Okay you are right perhaps an example would help. I am doing this:

my @files = @{ $sftp->ls( $conf{'remdir'} ) };

foreach my $ref ( @files )
{
next if $ref->{filename} eq "." || $ref->{filename} eq "..";
print $ref->{filename} . "\n"
}


However, no matter what I do dealing with $ref always seems to be
empty. When I refer to 'handle' I mean how I am supposed to handle the
object I am not referring to file handles or any other type of handle,
just the fact that I have data coming in, but I am not sure how I can
get my script to handle the data since there I don't seem to be able to
access the contents of the Net::SFTP::Attributes object.

Paul Lalli wrote:
> bmaynard@geekserv.com wrote:
> > Paul Lalli wrote:
> > > bmaynard@geekserv.com wrote:
> > > > Does anyone know how to handle a Net::SFTP::Attributes object? An
> > > > example would be awesome if anyone can provide?
> > >
> > > What was wrong with the descriptions and example you found when you
> > > looked up the documentation to the module?
> > >
> > > http://search.cpan.org/~dbrobins/Net-SFTP-0.10/lib/Net/SFTP/ Attributes.pm
> > The information in the documentation is very terse, and really doesn't
> > give a good description on how to handle the data or at least a
> > description on what format it is stored in.
>
> I don't at all understand what you're getting at. The documentation is
> "terse" because there's very little to say about it. There's nothing
> complicated. The size() method returns the size (a number of bytes).
> The atime() method returns the last access time of the file (a number,
> I'm sure. Presumably seconds since the epoch, like stat() itself
> returns. A simple printing of that value would confirm it.
>
> Can you be any more specific about what parts you don't understand?
> You've twice now used the term "handle", which has no meaning in this
> realm. What do you want to do with the data, and how are you being
> prevented from doing it?
>
> Paul Lalli

Re: Net::SFTP::Attributes

am 23.10.2006 21:48:23 von Paul Lalli

bmaynard@geekserv.com wrote:
> Okay you are right perhaps an example would help. I am doing this:
>
> my @files = @{ $sftp->ls( } ) };
>
> foreach my $ref ( @files )
> {
> next if $ref->{filename} eq "." || $ref->{filename} eq "..";
> print $ref->{filename} . "\n"
> }
>
>
> However, no matter what I do dealing with $ref always seems to be
> empty.

You really need to work on your usage of terminology when talking in
technical forums. "empty" is a term that applies to lists, arrays, and
hashes. It has no definate meaning for scalars. I don't know if you
mean that $ref is the empty string, or $ref is undefined, or $ref is a
reference to an empty array or an empty hash, or something else
entirely.

> When I refer to 'handle' I mean how I am supposed to handle the
> object I am not referring to file handles or any other type of handle,

I did not think you meant filehandles. I know you're using the word
'handle' as a verb. That still doesn't have any meaning. What does it
mean to "handle" the object? There are several things you can do to
objects. You can access their underlying referenced structures, you
can call their methods, etc. I don't know what you're trying to do
when you say "handle the object".

> just the fact that I have data coming in, but I am not sure how I can
> get my script to handle the data since there I don't seem to be able to
> access the contents of the Net::SFTP::Attributes object.

Okay, now that you've posted code, we can see what the actual problem
is. You've made no attempt above to access the Net::SFTP::Attributes
object. I'm guessing you've misread the documentation for the ls()
method of the Net::SFTP class. It says:

=======================================
$sftp->ls($remote [, $subref ])
Fetches a directory listing of $remote.

If $subref is specified, for each entry in the directory, $subref will
be called and given a reference to a hash with three keys: filename,
the name of the entry in the directory listing; longname, an entry in a
"long" listing like ls -l; and a, a Net::SFTP::Attributes object, which
contains the file attributes of the entry (atime, mtime, permissions,
etc.).

If $subref is not specified, returns a list of directory entries, each
of which is a reference to a hash as described in the previous
paragraph.
=======================================

So in your code, $ref is not a Net::SFTP::Attribute object. $ref is a
reference to a hash. That hash contains three key/value pairs. ONE of
those keys is 'a', and the value at that key is a Net::SFTP::Attribute
object.

Now, since you were not attempting to access any method of
Net::SFTP::Attribute, I have to assume that the mention of that entire
class is a gigantic red herring. So what is the *actual* problem
you're seeing with the above code? Is the loop not executing at all?
Is it looping through, but every $ref->{filename} is blank?

What debugging have you done for this? Have you printed out the
contents of $conf{'remdir'} to confirm it is what you think it is?
Have you printed Dumper(\@files) to see what's actually in this array?

Paul Lalli

Re: Net::SFTP::Attributes

am 25.10.2006 19:45:27 von bmaynard

Wow condescending, okay yes I have been programming for about 9 years,
when I ask a simple question on the correct usage of a module I would
prefer to get an answer that relates to my question rather than a
trumped up self important rant on my usage of the terms 'empty' and
'handle', if that is be the best you have to offer I would prefer not
to get any answer.

The code I sent you was a very heavily truncated snippet since the
actual code contains information my employeers would prefer not be sent
out, I was just attempting to give an example of what I am attempting
to do.



On Oct 23, 3:48 pm, "Paul Lalli" wrote:
> bmayn...@geekserv.com wrote:
> > Okay you are right perhaps an example would help. I am doing this:
>
> > my @files = @{ $sftp->ls( } ) };
>
> > foreach my $ref ( @files )
> > {
> > next if $ref->{filename} eq "." || $ref->{filename} eq "..";
> > print $ref->{filename} . "\n"
> > }
>
> > However, no matter what I do dealing with $ref always seems to be
> > empty.You really need to work on your usage of terminology when talking in
> technical forums. "empty" is a term that applies to lists, arrays, and
> hashes. It has no definate meaning for scalars. I don't know if you
> mean that $ref is the empty string, or $ref is undefined, or $ref is a
> reference to an empty array or an empty hash, or something else
> entirely.
>
> > When I refer to 'handle' I mean how I am supposed to handle the
> > object I am not referring to file handles or any other type of handle,I did not think you meant filehandles. I know you're using the word
> 'handle' as a verb. That still doesn't have any meaning. What does it
> mean to "handle" the object? There are several things you can do to
> objects. You can access their underlying referenced structures, you
> can call their methods, etc. I don't know what you're trying to do
> when you say "handle the object".
>
> > just the fact that I have data coming in, but I am not sure how I can
> > get my script to handle the data since there I don't seem to be able to
> > access the contents of the Net::SFTP::Attributes object.Okay, now that you've posted code, we can see what the actual problem
> is. You've made no attempt above to access the Net::SFTP::Attributes
> object. I'm guessing you've misread the documentation for the ls()
> method of the Net::SFTP class. It says:
>
> =======================================
> $sftp->ls($remote [, $subref ])
> Fetches a directory listing of $remote.
>
> If $subref is specified, for each entry in the directory, $subref will
> be called and given a reference to a hash with three keys: filename,
> the name of the entry in the directory listing; longname, an entry in a
> "long" listing like ls -l; and a, a Net::SFTP::Attributes object, which
> contains the file attributes of the entry (atime, mtime, permissions,
> etc.).
>
> If $subref is not specified, returns a list of directory entries, each
> of which is a reference to a hash as described in the previous
> paragraph.
> =======================================
>
> So in your code, $ref is not a Net::SFTP::Attribute object. $ref is a
> reference to a hash. That hash contains three key/value pairs. ONE of
> those keys is 'a', and the value at that key is a Net::SFTP::Attribute
> object.
>
> Now, since you were not attempting to access any method of
> Net::SFTP::Attribute, I have to assume that the mention of that entire
> class is a gigantic red herring. So what is the *actual* problem
> you're seeing with the above code? Is the loop not executing at all?
> Is it looping through, but every $ref->{filename} is blank?
>
> What debugging have you done for this? Have you printed out the
> contents of $conf{'remdir'} to confirm it is what you think it is?
> Have you printed Dumper(\@files) to see what's actually in this array?
>
> Paul Lalli

Re: Net::SFTP::Attributes

am 25.10.2006 20:02:24 von Paul Lalli

Ben wrote:
> Wow condescending, okay yes I have been programming for about 9 years,
> when I ask a simple question on the correct usage of a module I would
> prefer to get an answer that relates to my question rather than a
> trumped up self important rant on my usage of the terms 'empty' and
> 'handle', if that is be the best you have to offer I would prefer not
> to get any answer.
>
> The code I sent you was a very heavily truncated snippet since the
> actual code contains information my employeers would prefer not be sent
> out, I was just attempting to give an example of what I am attempting
> to do.

You've been programming for 9 years and you haven't figured out how to
write a descent error report?! Cripes! Have you considered a change
in careers?

You used terms that HAD NO MEANING, while asking people to help you fix
it. You may as well have brought your car to the mechanic and told him
that it doesn't "flap". Your mechanic would stare at you and say "what
the hell does 'flap' mean?" and then you'd get pissed at him for being
"condescending" about your usage of the word flap instead of just
fixing your damned car.

You want someone's help, you have to tell them what's going wrong. You
didn't do that. You made me and anyone else reading have to *guess*
what was going wrong. Oh, and by the way, I *did* solve your problem,
despite your repeated faulty error reports. You're welcome. Have you
noticed that NO ONE ELSE in this entire newsgroup even *attempted* to
help you? Why do you suppose that might be?

Friggin ungrateful ..... UGH.


Paul Lalli

PS. *That*, my friend, is condescending and insulting. My original
replies were helpful and explanatory. Learn the difference.

Re: Net::SFTP::Attributes

am 25.10.2006 21:01:40 von bmaynard

I apologise for being rude, that wasn't my intention, yes I should have
given a better description of my problems from the outset, when I wrote
that response I had just had an arguement with an manager and I vented
in the wrong place, I had actually figured out the problem when I saw
your response and I read through it just picking up on the wrong terms.

once again I do apologise, I am grateful for your time.

Ben

On Oct 25, 2:02 pm, "Paul Lalli" wrote:
> Ben wrote:
> > Wow condescending, okay yes I have been programming for about 9 years,
> > when I ask a simple question on the correct usage of a module I would
> > prefer to get an answer that relates to my question rather than a
> > trumped up self important rant on my usage of the terms 'empty' and
> > 'handle', if that is be the best you have to offer I would prefer not
> > to get any answer.
>
> > The code I sent you was a very heavily truncated snippet since the
> > actual code contains information my employeers would prefer not be sent
> > out, I was just attempting to give an example of what I am attempting
> > to do.You've been programming for 9 years and you haven't figured out how to
> write a descent error report?! Cripes! Have you considered a change
> in careers?
>
> You used terms that HAD NO MEANING, while asking people to help you fix
> it. You may as well have brought your car to the mechanic and told him
> that it doesn't "flap". Your mechanic would stare at you and say "what
> the hell does 'flap' mean?" and then you'd get pissed at him for being
> "condescending" about your usage of the word flap instead of just
> fixing your damned car.
>
> You want someone's help, you have to tell them what's going wrong. You
> didn't do that. You made me and anyone else reading have to *guess*
> what was going wrong. Oh, and by the way, I *did* solve your problem,
> despite your repeated faulty error reports. You're welcome. Have you
> noticed that NO ONE ELSE in this entire newsgroup even *attempted* to
> help you? Why do you suppose that might be?
>
> Friggin ungrateful ..... UGH.
>
> Paul Lalli
>
> PS. *That*, my friend, is condescending and insulting. My original
> replies were helpful and explanatory. Learn the difference.