Vita has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SFTP Foreign Issues using $sftp->ls
by salva (Canon) on Mar 01, 2016 at 07:22 UTC | |
by Vita (Novice) on Mar 01, 2016 at 18:00 UTC | |
by Vita (Novice) on Mar 01, 2016 at 17:59 UTC | |
|
Re: SFTP Foreign Issues using $sftp->ls
by Lotus1 (Vicar) on Mar 01, 2016 at 16:40 UTC | |
by salva (Canon) on Mar 01, 2016 at 19:47 UTC | |
by Lotus1 (Vicar) on Mar 01, 2016 at 19:54 UTC | |
by salva (Canon) on Mar 01, 2016 at 20:14 UTC | |
by Lotus1 (Vicar) on Mar 01, 2016 at 20:42 UTC | |
| |
by Vita (Novice) on Mar 03, 2016 at 21:40 UTC |