Watch for File on Windows share using Shell Script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Watch for File on Windows share using Shell Script
# 1  
Old 08-22-2008
Java Watch for File on Windows share using Shell Script

I want to poll a particular file on a Windows shared drive using shell script and copy it to a Unix directory if present.

Step wise execution:
1) Poll/watch for a file in the following location on Windows share:
(SRC_DIR=\\mum\dharmesh\research\ST_DXR_20080821 to DXR.xls)

2) If present, copy(FTP would be a suitable option) it to Unix directory
(DEST_DIR=/home/dharmesh/DXRFiles)
after renaming it.
I have figured out how to FTP and rename it, using the following piece of code:-

ftp -iv <hostname> << EOF
bin
cd "$SRC_DIR"

lcd "$DEST_DIR"
get "ST_DXR_20080821 to DXR.xls" "ST_DXR_20080821.xls"
close
bye
EOF


The real problem lies in Step 1.
Any suggestions/help needed.

Thanks,
dV
# 2  
Old 08-23-2008
If you have Samba, you don't need ftp. If you don't have Samba, how can you monitor the share? Are you trying to find out how to see the Windows share so you can monitor it, or are you trying to figure out how to periodically monitor something which you can already see? Anyway, smbclient or an SMB / CIFS mount is probably the crucial piece of infrastructure you need in order to get going.

Code:
while true; do
  cp /path/to/ugly/samba/share/name/"ugly windows file name here" /path/to/unix/file_name.xls && break
  sleep 300
done

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

2. Shell Programming and Scripting

To run a shell script in remote server from windows batch file

Hi all, i need to run a shell script on remote server. I have created file .bat file in windows server with following code, c:\Users\Desktop\putty.exe -ssh -pw password user@server ./script.sh i need to run the script.sh in my remote server Above command is not working, any... (4 Replies)
Discussion started by: rammm
4 Replies

3. Shell Programming and Scripting

share a shell script which can replace weird characters in directory or file name

I just finish the shell script . This shell can replace weird characters (such as #$%^@!'"...) in file or directory name by "_" I spent long time on replacing apostrophe in file/directory name added: 2012-03-14 the 124th line (/usr/bin/perl -i -e "s#\'#\\'#g" /tmp/rpdir_level$i.tmp) is... (5 Replies)
Discussion started by: begonia
5 Replies

4. Shell Programming and Scripting

Running remote system shell script and c binary file from windows machine using java

Hi, I have an shell script program in a remote linux machine which will do some specific monitoring functionality. Also, have some C executables in that machine. From a windows machine, I want to run the shell script program (If possible using java). I tried with SSH for this. but, in... (1 Reply)
Discussion started by: ram.sj
1 Replies

5. Shell Programming and Scripting

Script to copy User home folders to mounted windows share

First of all, let me state that I am a windows admin. I have a windows share mounted to /mnt/server I need a script that will either login as sudo or perform commands with sudo rights. I need the script to copy all of the users /home folders to the mounted windows share. Now If I can... (7 Replies)
Discussion started by: EricM
7 Replies

6. Shell Programming and Scripting

Can I use a shell script for deleting chunks from a watch folder?

Hello I have a unique problem of needing to delete large files slowly off of an XSan. I was wondering if there is a script I could use to delete 100gb chunks of files and folders that get placed in to a watch folder, slowly so as not to disrupt the other users. I would like to use Automator in... (0 Replies)
Discussion started by: ajsoto
0 Replies

7. IP Networking

how to share with windows

i m using Linux Mint on my computer and i m the server of shared Internet connection with windows machines. Internet sharing is working well with all the machines but file sharing is not working well. I can access the shared folders of other system with windows machine the windows machines cannot... (1 Reply)
Discussion started by: giri.nitp
1 Replies

8. Shell Programming and Scripting

Watch for File on Windows share using Shell Script

Watch for File on Windows share using Shell Script I want to poll a particular file on a Windows shared drive using shell script and copy it to a Unix directory if present. Step wise execution: 1) Poll/watch for a file in the following location on Windows share:... (1 Reply)
Discussion started by: dharam_v
1 Replies

9. Shell Programming and Scripting

like to share this beautiful shell script

Hello Everybody I recently got this beautiful shell script from my friend. I like to share it with every body as I am bit new to shell scripting enviorment. I hope people in this site will like it. It is related to checking the filesystem threshold limit. After getting threshold limit of... (0 Replies)
Discussion started by: girish.batra
0 Replies

10. Linux

how i can share the file between unix or linux in windows ??

hello everybody i have one quetion :( about how i can share my file in windows to use it in linux explane i have to opreating system windows xp and linux fedore core and unix ( sun solaris 10 ) and i want to open me file that is storege in windows <<< want to open it in unix or... (4 Replies)
Discussion started by: msn22
4 Replies
Login or Register to Ask a Question