[Samba] automating smbclient tasks

Gareth gareth at bim7.com
Wed Aug 13 20:41:03 GMT 2003

Hi Vasiliy

I did something similar using Expect (http://expect.nist.gov/)

It's pretty easy to automate interactive applications where you can't use
shell scripts. I have used it for auotmating ftp transfers between servers


#! /usr/local/bin/expect -f

log_user 0

# time out setting (in seconds, -1 for never time out)
set timeout -1

# directory to tar
set tar_path "/usr3"
set tar_dir "V4release"
set tar_name "V4release.tar"
set tar_temp "/usr2/tmp"

# ftp server details
set ftp_host "jupiter.galaxy"
set ftp_user "downloads"
set ftp_pass ""


# make the tarball, pass z to gzip the archive
send_user "Making the tarball $tar_name, from $tar_path/$tar_dir\n"
exec tar cvf $tar_temp/$tar_name $tar_path/$tar_dir

# make the ftp connection
send_user "Attempting to connect to $ftp_host\n"
spawn ftp $ftp_host

expect -nocase "name"
send $ftp_user\r

expect -nocase "password"
send $ftp_pass\r

expect -nocase "transfer files"
send_user "User '$ftp_user' logged in to $ftp_host\n"
send "lcd $tar_temp\r"

expect -nocase "directory"
send "send $tar_name\r"

expect -nocase "complete"
send_user "Transfer of $tar_name complete\n\nClosing connection.\n"
send "exit\r"




Sorry to post all that to the list, and sorry again if the coding is crappy;
but hey, it works :-)

Good luck


> -----Original Message-----
> From: samba-bounces+gareth=bim7.com at lists.samba.org
> [mailto:samba-bounces+gareth=bim7.com at lists.samba.org]On Behalf Of
> Boulytchev, Vasiliy
> Sent: 13 August 2003 20:22
> To: samba at lists.samba.org
> Subject: [Samba] automating smbclient tasks
> Ladies and Gents,
>     My project requires me to share IIS log files with my Linux box.
> The outcome of this solution is using Webalizer instead of horrid
> Webtrends.  I have testing most of this procedure, Webalizer does great
> with the combined log files (using mergelog).  In any case, I need to
> script the download of the files from one server to another.  I use
> something of the following to connect to the IIS server:
> smbclient // -W my_domain -U username
> Next, I do
> recurse
> prompt
> mget blahblahblah
> exit
> Ok,  Is there a ways to script all of this using smbclient/anything
> commands?  Or am I stuck with perl?  At least passing the password would
> be helpful.
> THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> Vasiliy Boulytchev
> Colorado Information Technologies Inc.
> (719) 473-2800 x15
> <http://coinfotech.com/>
> --
> To unsubscribe from this list go to the following URL and read the
> instructions:  http://lists.samba.org/mailman/listinfo/samba

More information about the samba mailing list