[Samba] Deleting files on a remote PC Samba Server from a UNIX Script.

Eugene De Jager edejager at vinidex.com.au
Tue Jan 13 04:24:22 GMT 2004


Hi
 
I am hoping that you would be able to help me to "Deleting files on a remote
PC Samba Server from a UNIX Script.".
 
At present I can logon to the Server and un-tar a file to the Remote PC.
I can also delete files on the "Local Unix Box" in the same script.
 
Do you perhaps know how to delete files on the Remote Pc Samba Server using
the same script and Samba?.
 
Below is the script I'm using at present which is run via CRON.
 
Kind regards
Eugene.
 
 
HOME_DIR=/home/ibhar/   # Local machine directory
LOGFILE="/home/ibhar/log/"`date +"%y%m%d"`
SERVER=pcibhar

if [ ! -d "${HOME_DIR}/log" ]
then
   mkdir ${HOME_DIR}/log
fi
 
echo "Copying files to PCIBHAR started " `date` >> $LOGFILE
echo
"=======================================================================" >>
$LOGFILE
 
cd $HOME_DIR/MXP_REPORTS
 
tar cvf $HOME_DIR/backup.tar * 1>/dev/null
 
# Un-TAR the UNIX tar file onto the PC(pcibhar) Keeping the same dir
structure
smbclient \\\\${SERVER}\\ibharMXPReports "" -N -Ukho%khoi1 -Tx
$HOME_DIR/backup.tar >> $LOGFILE
 
# Delete files from the UNIX Box (VXLIVE)
smbclient \\\\${SERVER}\\ibharMXPReports "" -N -Ukho%khoi1 -c del
\\QUOTES\\*.csv <file://\\QUOTES\\*.csv>  >> $LOGFILE
 
# Delete files from the UNIX Box (VXLIVE)
smbclient \\\\${SERVER}\\ibharMXPReports "" -N -Ukho%khoi1 -c del
\\SALES_HISTORY\\ACCOUNTS\\*.csv <file://\\SALES_HISTORY\\ACCOUNTS\\*.csv>
>> $LOGFILE
 
# Directory listing of UNIX Box (VXLIVE)
smbclient \\\\${SERVER}\\ibharMXPReports "" -N -Ukho%khoi1 -c dir >>
$LOGFILE
 
echo
"======================================================================="
>>$LOGFILE
echo "Copy files to PCIBHAR completed " `date` >> $LOGFILE



More information about the samba mailing list