0

I am trying to write shell script in Linux server, which will notify the user about arrival of new file on Windows shared drive.

Most of the solutions suggests following approach:

  1. Mount Windows shared folder on Linux
  2. Enable polling through Linux shell scripting.

However I want to achieve this operation without mounting Windows drive on Linux, as mount operation is not allowed due to access issues.

3
  • This is not clear. Are you wanting to use Gnu/Linux or not? Where do you want to run this program? Apr 29, 2020 at 10:03
  • We want to use Linux. Script will run in Linux machine and poll the windows shared folder.
    – Prakhar
    May 3, 2020 at 7:21
  • How is it shared? Is it a network share? What is hosting the share? If it is a network share hosted in Gnu/Linux, then it is trivial, and can be done with little resources. If hosted on MS-Windows, then it may be better to put the monitoring there, as it has assess to change events. May 3, 2020 at 9:11

1 Answer 1

0

This might work:

smbclient //server/share -A=/some/auth/file -TNc /some/timestamp/file - '/some/folder/*'
touch /some/timestamp/file

where:

  • //server/share is your remote Windows share;
  • /some/auth/file is a file containing your credentials for accessing that share;
  • /some/timestamp/file is a file you use as a timestamp;
  • /some/folder is a folder on the remote share you want to find new files in;

The idea is that you consider any file on the remote share newer than this local /some/timestamp/file as "new". If the cmbclient command receives anything other than 0 byte, you have new files. You may also pipe the standard output of the smbclient command to "| tar tvf -" to get a list of the new files.

The problem with this approach is that it actually copies all the new files' contents over. If you have large files on the remote share, that would be a huge waste of bandwidth. If the remote system has a command similar to the Linux find, you may run that instead of using tar.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .