The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Deleting a file in Windows drive from Unix script anilvaranasi_02 Shell Programming and Scripting 2 12-11-2008 09:33 PM
Perl Scripting for monitoring logs solitare123 UNIX for Dummies Questions & Answers 1 06-25-2008 07:49 AM
Map Drive From Windows To Apache Shared Drive? gseyforth UNIX for Dummies Questions & Answers 0 02-23-2008 07:56 PM
copy file from UNIX to shared directory sireesha15 UNIX for Dummies Questions & Answers 5 11-13-2006 04:00 PM
how to access a windows shared drive from HPUX? nicky88 HP-UX 5 09-28-2004 12:55 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-02-2009
zulfikarmd zulfikarmd is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 16
Thumbs up 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 (permalink)  
Old 07-03-2009
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
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 (permalink)  
Old 07-03-2009
zulfikarmd zulfikarmd is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 16
Quote:
Originally Posted by Smiling Dragon View Post
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 (permalink)  
Old 08-09-2009
Smiling Dragon's Avatar
Smiling Dragon Smiling Dragon is offline Forum Advisor  
Disorganised User
  
 

Join Date: Nov 2007
Location: New Zealand
Posts: 922
Quote:
Originally Posted by zulfikarmd View Post
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.
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0