file monitoring using unix scripting on shared drive


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting file monitoring using unix scripting on shared drive
# 1  
Old 07-02-2009
MySQL file monitoring using unix scripting on shared drive

Hi all,

I have a query and need advise. is it possible to have a script which will monitor file/s on network shared drive (windows machine)? Is there a way i can monitor a file is available on shared drive and move it over to unix machine for further processing? Any guidance or advice much appreciated.

Thank you.
# 2  
Old 07-03-2009
Sure, there's a bunch of ways you can do this:
  • Run periodic ftp listings to see when new files show up, then ftp it out.
  • Use smbclient (comes with most samba implementations) to do much the same
  • If your OS supports it, samba mount the shared filesystem and then treat it like a local one
You'll want to think about move vs copy as well, also consider doing filesize comparisons after copying the file to make sure you have it complete before deleting it from the share.
# 3  
Old 07-03-2009
Quote:
Originally Posted by Smiling Dragon
Sure, there's a bunch of ways you can do this:
  • Run periodic ftp listings to see when new files show up, then ftp it out.
  • Use smbclient (comes with most samba implementations) to do much the same
  • If your OS supports it, samba mount the shared filesystem and then treat it like a local one
You'll want to think about move vs copy as well, also consider doing filesize comparisons after copying the file to make sure you have it complete before deleting it from the share.
Thanks mate. We have smbclient set up and I am able to move/copy files onto unix machine periodically. But what i want to do is to run this command once when file is available on the shared drive and then move the files to unix machine. is this possible? any hints?
# 4  
Old 08-09-2009
Quote:
Originally Posted by zulfikarmd
Thanks mate. We have smbclient set up and I am able to move/copy files onto unix machine periodically. But what i want to do is to run this command once when file is available on the shared drive and then move the files to unix machine. is this possible? any hints?
The main problem you'll have is telling when the file has finished writing out to your shared drive. Periodically doing a file list will show you when it appears but you may jump in and grab half a file that way. If you have control of the process that's creating the file you are looking for, have it write to one file (with a suffix something like '.part') then rename it once it's finished writing it out.
If you don't have control of the creation process, you will need to either rely on timing (ie see the file appear, wait X seconds, then copy it, test the file size, then delete), but that's very dangerous of course.
If you know what the 'proper; file size will be, you can have your watcher script look only for new files that are also of the correct size, but that's not always a luxury you'll have.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

File transfer from UNIX to shared location using shell script

Is there any possible way transfering the file from unix to shared location using shell script. i had created the batch script to fetch the files from unix to shared location and it works fine. Due to some problem in windows unable to transfer the file to shared location automatically. can anyone... (2 Replies)
Discussion started by: venkat918
2 Replies

2. Shell Programming and Scripting

How to FTP the file in to the Windows shared drive?

Hi All, How to FTPing file from Unix server to Windows Shared drive location. Thanks, Suman B (1 Reply)
Discussion started by: sumanmca2006
1 Replies

3. Shell Programming and Scripting

Copy file from UNIX to shared location

Hi All, I want to transfer file from UNIX to shared locataion . Shared location doesn't resides on my system. Can somebody tell me is there any way i can transfer file from UNIX to shared location without using any tool WINSCP. Thanks, Amit (1 Reply)
Discussion started by: Amit786
1 Replies

4. UNIX for Dummies Questions & Answers

Need help to move .csv file from UNIX path to windows shared drive or c:\ drive

Hi Guys, Can any one help me on this. I need help to move .csv/.xls file from unix path to windows shared drive or c:\ drive? Regards, LKR (1 Reply)
Discussion started by: lakshmanraok117
1 Replies

5. Shell Programming and Scripting

Need help to move .csv file from UNIX path to window c: shared drive

Hi Guys, I need to move myfile.csv file from unix path(\oracle_home) to window c:\ shared drive h:\. Thanks in advance! Regards, Lakshman (1 Reply)
Discussion started by: lakshmanraok117
1 Replies

6. Linux

Permission denied issue on a Shared drive

Hi, I have 2 linux servers. One of them has a mount which I have mapped to a shared samba directory on the other server. Below will help you understand better. smb.conf on Server1: workgroup = WRKGRP netbios name = smbserver security = SHARE load printers = No default service = global... (11 Replies)
Discussion started by: satishrao
11 Replies

7. UNIX for Dummies Questions & Answers

Map Drive From Windows To Apache Shared Drive?

Anyone know how I can map a windows drive to an apache shared drive? In my httpd.conf file, I have: Alias /merc_rpts/ "/u/merc_rpts/" <Directory "/u/merc_rpts"> Options Indexes </Directory> I'm able to bring up a browser and see the contents of this folder. In... (0 Replies)
Discussion started by: gseyforth
0 Replies

8. UNIX for Dummies Questions & Answers

copy file from UNIX to shared directory

Hi, I want to copy a file from unix machine to a shared windows directory. i tried using the ftp command but i was able to transfer the file only to my local directory. Is there any way we can transfer/copy the files from unix to windows shared directory.......... Please help. Thanks (5 Replies)
Discussion started by: sireesha15
5 Replies

9. HP-UX

how to access a windows shared drive from HPUX?

Dear Unix Gurus, I am very very new to UNIX. Apreciate your advice/guidence on the following. I have a HPUX machine and i want to copy some files from this machines to a windows shared drive. I am not sure how to go about it. To my little knowledge i think it is not straight... (5 Replies)
Discussion started by: nicky88
5 Replies
Login or Register to Ask a Question