Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

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";

Replies are listed 'Best First'.
Re: Trying to move files from Linux to Windows using smbclient
by pmonk4ever (Friar) on Sep 16, 2009 at 19:51 UTC
    Hmmmm,

    How about trying to add use diagnostics; to your script and see if you get more descriptive text for the error. The message you currently get is very generic in nature, not much help.

    pmonk4ever

    "No trees were harmed in the creation of this node. However, a rather large number of electrons were somewhat inconvenienced."

    Update: In the description on CPAN: SmbClientParser work with output of bin smbclient, so it doesn't work on win platform. (but query of win platform work of course)

    Also, there is a Debug option in the module: Debug1 That might help.

    Last but not least, look on the ActiveState site for Alian's ToDo: "Write a wrapper for ActiveState release on win32"

    Good hunting!