I crave the Monks benevolence in trying to get a script working with Filesys::SmbClientParser. I'm trying to move some large MP3 and WAV files from a Linux box to a Windows share via Samba and thought that this might be the package from CPAN and some searching on Perlmonks (and is probably hampered by my newbiness on Linux). I'm trying to move the files from directories in var/spool/asterisk/1 to hostname\share on Windows.
I've tried to iterate over the relevant directories and connect the share for each file and put it but I keep getting NT_STATUS_BAD_NETWORK_NAME for the line with the put command and would be grateful for some advice on getting this script working.
#!usr/bin/perl -w use strict; use File::Find; use Filesys::SmbClientParser; my $smb = new Filesys::SmbClientParser (undef, ("User"=>$user, "Password"=>$pass, "Debug"=>1)); $smb->Host("hostname"); $smb->Share("share"); my @files; my @dir ('var/spool/asterisk/1/a'); find (sub { push @files, $_ if /\.mp3$/i}, @dir); find (sub { push @files, $_ if /\.wav$/i}, @dir); foreach my $content (@files) { $smb->get($content); $smb->cd('\\\\hostname\\share'); $smb->put($content); print "Moved file: " . $content . "\n"; } print "File move complete\n";

In reply to Trying to move files from Linux to Windows using smbclient by Anonymous Monk

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.