Automating smbclient nightly copies

Automating smbclient nightly copies

Post by Rich Grav » Wed, 24 Dec 1997 04:00:00

>THIS IS MY ATTEMPT AT AUTOMATION (I will put this in a crontab):
>    UNIX> smbclient '\\pc-name\share' -I 123.456.78.90 <<!<return>
>          <return>
>          <return>
>          put /tmp/file.txt file.txt<return>
>          q<return>
>          !<return>

Specify the password on the command line and use -c.

 smbclient '\\pc-name\share' password -d 0 -I 123.456.78.90 -c \
  'put /tmp/file.txt file.txt'

You definitely want to run -d 0 to avoid a bunch of mail.

I'm currently "polling" domain controller and home directory status with
this tangled mess. There is a history to the variables and interface used.


$share = ($0 =~ /dc/) ? "NETLOGON" : "Users";

while($ARGV[0] =~ /^-/) {
   $_ = shift;
   if (/^-s/) {


$server = shift if ($#ARGV == 0);

$out= system("/usr/bin/smbclient \\\\\\\\$server\\\\$share \
$passwd -U $username -W $domain -d 0 -c quit 2\&> /dev/null");

exit $out;


Automating smbclient nightly copies

Post by John Gian » Thu, 25 Dec 1997 04:00:00

There is a need to automate the push of a UNIX file directly onto a PC.

Does anyone know how to automate the manual steps below?
    (For test purposes, assume foo.mbx exists in /tmp on the UNIX machine)
    (For test purposes, assume 123.456.78.90 is the IP address of the PC)

    UNIX>      smbclient '\\pc-name\share' -I 123.456.78.90<return>
    Password:  <return>
    smb: \>    put /tmp/foo.mbx file.mbx<return>
    smb: \>    q<return>

THIS IS MY ATTEMPT AT AUTOMATION (I will put this in a crontab):
    UNIX> smbclient '\\pc-name\share' -I 123.456.78.90 <<!<return>
          put /tmp/file.txt file.txt<return>
    But, the darn thing _still_ asks for the pasword so it won't automate.

Do any unix_users know how to automate this smbclient push command?



Automating smbclient nightly copies

Post by John Gian » Thu, 25 Dec 1997 04:00:00

: Does anyone know how to automate the manual steps below?

We figured it out this evening from folks from the UK and the US.

Here is the result:

Wow -- this new PC/UNIX interoperabililty capability is POWERFUL!

Together, we solved automated periodic GET/PUT of files between PC & UNIX!

(Solved from the UNIX side. Note: we're still working on the PC crontab side).
John Gianni, Andrew Beckett, Kent Lewallen, Tom Belpasso, Dave Morris, 12/97

Here's what worked today:
Thanks to the combined help from experts such as:
  Andrew Beckett:   Powerful ban-spam tools create the UNIX file spam.mbx
  Kent Lewallen:    PushFile/crontab scripts push that UNIX file onto the PC
  Tom Belpasso:     Smbcopy -N option eliminates the password query
  Dave Morris:      Eudora PC test-case user eliminating spam

Here's a simple solution for periodic PUT of UNIX files onto a PC from UNIX:
STEP 1:  Create the desired UNIX file to put onto the PC.

         This method works with _any_ UNIX file.

         In our test case, Dave Morris created spam.mbx using Andrew Beckett's
         supremely powerful Cadence ban-spam procmail filter. (Dave was on
         Alta's "mastt" server, which isn't even running procmail and it
         still worked perfectly!)

         This creates, for example, the text file /tmp/spam.mbx
STEP 2:  Add a crontab entry on UNIX to nightly push the file to the PC:
         10 3 * * * /usr/local/bin/pushFile > /dev/null 2>&1

         Or, if you want the error output:

         10 3 * * * /usr/local/bin/pushFile
STEP 3:  On the PC, simply use the file any way you want. It's there for you.

         In this case, we simply start up Eudora. Eudora not only perfectly
         recognized the mbx file, but, it also builds a table-of-contents
         on the fly! (Notice this allows Cadence pc_users to turn an
         outdated POP3 client such as Eudora 3 into an IMAP client of sorts.)
For your benefit, here is the UNIX pushFile script from Kent Lewallen:
(All you need is the smbclient line, but, Kent kindly added intelligence
for graceful exit if a PC is unconnected or if the IP address changes:

---<cut here>---
#!/bin/csh -f

set IP = 123.456.78.90
# ping this IP with 8 bytes for no more than 1 sec
/usr/sbin/ping $IP 8 1
if ($status != 0) then
   /usr/ucb/echo "ERROR. $0  ping failed"
   exit 1

/usr/local/samba/bin/smbclient '\\pc-jjg\public' -I 123.456.78.90 -N <<!
put /tmp/spam.mbx spam.mbx
---<cut here>---


1. Automating smbclient to copy yesterdays logfile

Hi all,

I want to automate smbclient to copy yesterdays log file from a webserver.
The logfiles names are in the format:
where MM = month, DD = day and YYYY = year.
I guess I can use a date type function to build a string containing the date
for yesterdays log file, which I can pass to smbclient to retrieve?

Thanks in advance.

Reuben Pearse

2. iptables flush script...

3. ftp automated batch copy

4. Documentation/network/ppp_generic.txt

5. Quota patches for 2.5 - 9

6. "secure" rshd package (or any automated, non-ftp file copying)

7. Ethernet Interrupt Problems!?

8. ftp automated batch copy

9. Garbled log lines in nightly email

10. a script for nightly backups

11. Crossplatform Nightly Build of Automake C-project

12. Nightly regression runs against current bk tree