If you don’t want to mess around with windows scripting and you just want to get the job done, well, the easiest method is sometimes the not so obvious… use smbclient! It’s part of Samba (no, not the samba style of music).
I’ve created a very simple script to automate smbclient. It assumes that the login name, password and the directory on each of the windows boxes are the same.
Note that the directory is relative to the windows share. For example the following two windows machines share the sybase directory as “sybase”. Whether actual location of sybase is located on the C drive or somewhere else, doesn’t really matter as it is simply “\\<server>\sybase” to the rest of the network.
c:\sybase shared as \\mywin2k\sybase
d:\sybase shared as \\mywin2k3\sybase
Put either the ip address or the name of each of the windows machines you want to upload your file to into the smb_ips file.
192.168.0.70
192.168.0.71
192.168.0.17
192.168.0.101
192.168.0.23
192.168.0.24
192.168.0.25
Change the smb_user and smb_pass to your windows login/password. Next, change upload_file to point to the file you need to upload to the windows box. Finally, change the upload_dir to the directory on the windows box you want to upload the file to.
#!/bin/bash smb_user="login" smb_pass="password" # EBF 13464.zip is Sybase ASE 12.5.1 esd 13 for windows upload_file="EBF13464.zip" upload_dir="sybase" while read ip; do echo Uploading ${upload_file} to ${ip} smbclient --user $smb_user \\\\${ip}\\${upload_dir} $smb_pass < <EOF put ${upload_file} exit EOF done < smb_ips
OUTPUT:
Uploading EBF13464.zip to 192.168.0.70
Domain=[DONUT_COOKIE] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
putting file EBF13464.zip as \EBF13464.zip (330.5 kb/s) (average 330.5 kb/s)Uploading EBF13464.zip to 192.168.0.71
Domain=[DONUT_COOKIE] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
putting file EBF13464.zip as \EBF13464.zip (331.5 kb/s) (average 331.5 kb/s)Uploading EBF13464.zip to 192.168.0.17
Domain=[DONUT_COOKIE] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
putting file EBF13464.zip as \EBF13464.zip (330.4 kb/s) (average 330.4 kb/s)Uploading EBF13464.zip to 192.168.0.101
Domain=[DONUT_COOKIE] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
putting file EBF13464.zip as \EBF13464.zip (335.4 kb/s) (average 335.4 kb/s)Uploading EBF13464.zip to 192.168.0.23
Domain=[DONUT_COOKIE] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
putting file EBF13464.zip as \EBF13464.zip (327.5 kb/s) (average 327.5 kb/s)Uploading EBF13464.zip to 192.168.0.24
Domain=[DONUT_COOKIE] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
putting file EBF13464.zip as \EBF13464.zip (318.4 kb/s) (average 318.4 kb/s)Uploading EBF13464.zip to 192.168.0.25
Domain=[DONUT_COOKIE] OS=[Windows 5.0] Server=[Windows 2000 LAN Manager]
putting file EBF13464.zip as \EBF13464.zip (329.5 kb/s) (average 329.5 kb/s)