Automating smbclient to copy yesterdays logfile

Automating smbclient to copy yesterdays logfile

Post by Reuben Pears » Thu, 12 Dec 2002 20:29:47



Hi all,

I want to automate smbclient to copy yesterdays log file from a webserver.
The logfiles names are in the format:
accessMMDDYYYY.log
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

 
 
 

Automating smbclient to copy yesterdays logfile

Post by Ramprasad A Padmanabha » Fri, 13 Dec 2002 15:12:20



> Hi all,
> I want to automate smbclient to copy yesterdays log file from a webserver.
> The logfiles names are in the format:
> accessMMDDYYYY.log
> 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


Create a date string like this
DATE=`date +'%m%d%Y'`

Now you can move the File
mv $SRCDIR/access$DATE.log $DESTDIR

or if it is a function

functioname $SRCDIR/access$DATE.log

--
Ramprasad A Padmanabhan
Sr Software Engineer
Netcore Solns Pvt Ltd
Mumbai
ph - (022) 4628000

 
 
 

1. Automating smbclient nightly copies

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.

#!/usr/local/bin/perl

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

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

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

2. Automatically unmount samba partitions at shutdown?

3. detecting automated accesses in logfiles

4. pronunciation

5. Get day before yesterday's and yesterday's date.

6. quick Korn question on reading input from a comma delimited file:

7. ftp automated batch copy

8. Restricting access from network for different users.

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

10. ftp automated batch copy

11. (1 on 1 copy for CD) CD copy of PSX-CD's

12. New HDD copy; using "Drive Copy" program (W98) to dupe Linux