TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:8923] SMB/scripting question



Hello all:

How about a Perl script along the lines of:

------------------------------------------------
#!/usr/bin/perl -w

my $cmd = q[smbclient //process/c <password> -c 'ls /bin/running.txt'];

my $output = `$cmd`;

if ($output =~ /not found/i) {
	print "File not found.\n";
} else {
	print "File exists.\n";
}
------------------------------------------------

Regards,
John

> From: "Carl Wilhelm Soderstrom" <carls@agritech.com>
> Date: Mon, 04 Oct 1999 12:42:31 -0700
> Subject: [TCLUG:8923] SMB/scripting question
>
>         I need to check for the existence of a file on an SMB share (and if
> it exists at at time that it shouldn't, mail me an error message). I could
> do an smbmount, do an ls for the file, get the return code, and (I think)
> based on that, determine what to do. (then unmount the share)
>         however, I found that smbclient can execute commands
> non-interactively; and I was wondering if that might be more efficient than
> smbmounting/umounting. this command will do an ls for the existence of the file:
> smbclient //process/c <password> -c 'ls /bin/running.txt'
>
> but how do I get a useful conditonal statement to act upon the results of that?
> is it worthwhile to do that? or should I just write a script to mount the
> share, check for the file, then unmount the share?
>
> Carl Soderstrom
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tclug-list-unsubscribe@mn-linux.org
> For additional commands, e-mail: tclug-list-help@mn-linux.org
>