What am I doing wrong ... as no files are being returned. I have tried several different ways as in the following code. Also replacing '/' with '.' and getting the same result. Thanks in Advance.

my $curdir = $sftp->cwd; print"\ncurdir = $curdir"; $envment = "b"; $pat1 = $envment . "REP_*.dat"; $pat2 = $envment . "REQ_*.report"; $pat3 = $envment . "REQ_*.report.*"; $pat4 = $envment . "REQ_*.req.copied"; $ls1 = $sftp->ls('/', names_only => 1, wanted=>qr/$pat1/); $ls2 = $sftp->ls('/', names_only => 1, wanted=>qr/$pat2/); $ls3 = $sftp->ls('/', names_only => 1, wanted=>qr/$pat3/); $ls4 = $sftp->ls('/', names_only => 1, wanted=>qr/$pat4/); print "\nH1. Attempt to list files "; foreach $file ( @{$ls1}, @{$ls2}, @{$ls3}, @{$ls4} ) { print "\nH1. $file "; } @ls1 = @{ $sftp->ls('/', names_only => 1, wanted=>qr/$pat1/) }; @ls1 = @{ $sftp->ls('/', names_only => 1, wanted=>qr/$pat2/) }; @ls1 = @{ $sftp->ls('/', names_only => 1, wanted=>qr/$pat3/) }; @ls1 = @{ $sftp->ls('/', names_only => 1, wanted=>qr/$pat4/) }; print "\nH2. Attempt to list files "; foreach $file ( @{$ls1}, @{$ls2}, @{$ls3}, @{$ls4} ) { print "\nH2. $file "; } ##my $files = $sftp->glob("/b*.dat", names_only => 1); ##print "\n11. $files"; $file{pattern1} = $envment . "REP_*.dat"; $file{pattern2} = $envment . "RPi_*.dat"; while ( ( $key, $pattern ) = each ( %file ) ) { print "\nKey = $key, Pattern = $pattern"; $ls = $sftp->ls('.', names_only => 1, wanted=>qr/$pattern/); print "\nH3. Attempt to list files "; foreach $file ( @{$ls} ) { print "\nH3. File = $file"; } ## end foreach $file ( @files ) } ## end while

Snippet of result from Debug

H1. Attempt to list files #26095 1456788603.00000 _rel2abs: '/' --> '/'

#26095 1456788603.00000 _rel2abs: '/' --> '/'

#26095 1456788603.00000 _queue_msg: queueing msg len: 10, code:11, id:29 ... 1

00 00 00 0a 0b 00 00 00 1d 00 00 00 01 2f | ............./

#26095 1456788603.00000 _get_msg: waiting for message... 1

#26095 1456788603.00000 _do_io: _do_io connected: 1

#26095 1456788603.00000 _do_io: _do_io select(-,-,-, undef)

#26095 1456788603.00000 _do_io: _do_io write queue: 14, syswrite: 14, max: 65536, $!:

00 00 00 0a 0b 00 00 00 1d 00 00 00 01 2f | ............./

#26095 1456788603.00000 _do_io: _do_io select(-,-,-, undef)

#26095 1456788603.00000 _do_io: _do_io read sysread: 17, total read: 17, $!:

00 00 00 0d 66 00 00 00 1d 00 00 00 04 00 00 00 00 | ....f............

#26095 1456788603.00000 _get_msg: got it!, len:13, code:102, id:29, status: -

66 00 00 00 1d 00 00 00 04 00 00 00 00 | f............

#26095 1456788603.00000 opendir: new remote dir '/' open, rid:

00 00 00 00 | ....

#26095 1456788603.00000 _queue_msg: queueing msg len: 13, code:12, id:30 ... 1

00 00 00 0d 0c 00 00 00 1e 00 00 00 04 00 00 00 00 | .................

#26095 1456788603.00000 _get_msg: waiting for message... 1

#26095 1456788603.00000 _do_io: _do_io connected: 1

#26095 1456788603.00000 _do_io: _do_io select(-,-,-, undef)

#26095 1456788603.00000 _do_io: _do_io write queue: 17, syswrite: 17, max: 65536, $!:

00 00 00 0d 0c 00 00 00 1e 00 00 00 04 00 00 00 00 | .................

#26095 1456788603.00000 _do_io: _do_io select(-,-,-, undef)

#26095 1456788603.00000 _do_io: _do_io read sysread: 14587, total read: 14587, $!:

00 00 38 f7 68 00 00 00 1e 00 00 00 64 00 00 00 01 2e 00 00 00 39 64 72 77 78 72 77 78 72 77 78 | ..8.h.......d........9drwxrwxrwx

20 20 20 20 37 20 72 6f 6f 74 20 20 20 20 20 6f 74 68 65 72 20 20 20 20 20 20 39 34 32 30 38 30 | 7 root other 942080

20 46 65 62 20 32 39 20 31 38 3a 30 37 20 2e 00 00 00 0f 00 00 00 00 00 0e 60 00 00 00 00 00 00 | Feb 29 18:07 ...........`......

00 00 01 00 00 41 ff 56 d4 d0 56 56 d4 cf 1b 00 00 00 02 2e 2e 00 00 00 3a 64 72 77 78 72 77 78 | .....A.V..VV............:drwxrwx

72 77 78 20 20 20 20 37 20 72 6f 6f 74 20 20 20 20 20 6f 74 68 65 72 20 20 20 20 20 20 39 34 32 | rwx 7 root other 942

30 38 30 20 46 65 62 20 32 39 20 31 38 3a 30 37 20 2e 2e 00 00 00 0f 00 00 00 00 00 0e 60 00 00 | 080 Feb 29 18:07 ............`..

00 00 00 00 00 00 01 00 00 41 ff 56 d4 d0 56 56 d4 cf 1b 00 00 00 03 62 69 6e 00 00 00 3b 64 2d | .........A.V..VV.......bin...;d-

2d 78 2d 2d 78 2d 2d 78 20 20 20 20 32 20 72 6f 6f 74 20 20 20 20 20 6f 74 68 65 72 20 20 20 20 | -x--x--x 2 root other

20 20 20 20 34 30 39 36 20 4e 6f 76 20 20 35 20 20 32 30 30 34 20 62 69 6e 00 00 00 0f 00 00 00 | 4096 Nov 5 2004 bin.......

00 00 00 10 00 00 00 00 00 00 00 00 01 00 00 40 49 54 cd aa 42 41 8b d3 6b 00 00 00 03 65 74 63 | ...............@IT..BA..k....etc

00 00 00 3b 64 72 2d 2d 72 2d 2d 72 2d 2d 20 20 20 20 32 20 72 6f 6f 74 20 20 20 20 20 6f 74 68 | ...;dr--r--r-- 2 root oth

65 72 20 20 20 20 20 20 20 20 34 30 39 36 20 4e 6f 76 20 20 35 20 20 32 30 30 34 20 65 74 63 00 | er 4096 Nov 5 2004 etc.

00 00 0f 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 01 00 00 41 24 56 d4 13 87 41 8b d3 6b 00 | .....................A$V...A..k.

00 00 07 6e 6f 74 69 63 65 73 00 00 00 3f 64 72 77 78 72 77 78 72 77 78 20 20 20 20 32 20 6f 70 | ...notices...?drwxrwxrwx 2 op


In reply to SFTP Foreign Issues using $sftp->ls by Vita

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.