in order to verify if the backups are running properly I want to check timestamps of some directories in a cifs share. I need to check this from a linux host and I nearly got it working using http://search.cpan.org/~alian/Filesys-SmbClient-3.1/SmbClient.pm

If I hard code the share name, it works. I want to reuse the code allowing the share to be entered a the command line, and I hit a wall with the "$" character. In cifs (windows shares) "$" at the end of the share name means 'this share is hidden', so it is not discoverable using the Windows explorer (yes, security through obscurity).

I need to check dirs in shares with or without '$" at the end of the share name.

So using this code works:

use Filesys::SmbClient; my $smb = Filesys::SmbClient->new( username => $user, password => $pwd, workgroup => $workgroup, debug => $debug, ); my $fd = $smb->opendir("smb://filer1/db_backups\$/rest") or die "$!\n" +;
But this does not:
print "[$host], [$share], [$dir], [$user], [$pwd], [$workgroup], [$deb +ug]\n"; # change share name from share$ to share\$ if ( $share =~ m/^.*\$$/ ) { $share =~ s/\$/\\\$/g; print "share is [$share]\n"; } else { print "share is $share\n"; } my $full_path = 'smb://' . $host . '/' . $share . '/' . $dir ; print "[$full_path]\n"; my $fd = $smb->opendir("$full_path") or die "$!\n";
[filer1], [db_backups$], [rest], [user], [password], [workgroup], [100 +] share is [db_backups\$] Full path is [smb://filer1/db_backups\$/rest] No such file or directory
Obviously, something is going wrong with the share name conversion, but I do not see what. Any help greatly appreciated.

Update:

Finally resolved by using single quotes around the share name and removing the if loop that changed the sharename if it contained a $ sign. O well.


In reply to (RESOLVED): Filesys::SmbClient problem by natxo

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.