finding a way to wait for an unknown named file to appear in a directory and then doing something with it












0















I have a dir called /media/simc/, I want to to set something up to monitor /media/simc/, and when a file is put in it (from this machine or any other on the network, it is a network mounted dir itself), I want to take that file and do stuff with it ("stuff", in this case meaning reading the contents and passing them to a command)
(I also want to exclude a specific filename from the watch, say notest.txt)



The issues are I do not know what this file is going to be named, but I do know one thing it is not going to be named that I need excluded, and I have zero clue what I'm doing generally.



I thought inotifywait was the answer after some googling, and set up a quick demo for myself with this just to test that it would see stuff I put in there and do...stuff
inotifywait -m /media/simc/ -e create
(also tried with moved-to but not related really)



Then made a file in the dir and...nothing. After some troubleshooting I found out that I have to create a file in it through the machine itself, whereas my usecase is I have this directory available on the network and will be moving files into it from other machines, which when I do does not seem to proc the output.



So using nano test gives me what I want:
/media/simc/ CREATE .test.swp
but when I move a file into the directory or create one in it from another machine, no dice.



What are my options?










share|improve this question







New contributor




user863492 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • If it helps any currently what I'm doing is I manually run a bash script that prompts the user to paste in the stuff in the file then mess with it a little and load it into the command (simcraft, for anyone curious). I'm trying to automate it more so I can just save the file into this directory and have the machine automagically grab the contents, mess with them and pass them on.

    – user863492
    32 mins ago
















0















I have a dir called /media/simc/, I want to to set something up to monitor /media/simc/, and when a file is put in it (from this machine or any other on the network, it is a network mounted dir itself), I want to take that file and do stuff with it ("stuff", in this case meaning reading the contents and passing them to a command)
(I also want to exclude a specific filename from the watch, say notest.txt)



The issues are I do not know what this file is going to be named, but I do know one thing it is not going to be named that I need excluded, and I have zero clue what I'm doing generally.



I thought inotifywait was the answer after some googling, and set up a quick demo for myself with this just to test that it would see stuff I put in there and do...stuff
inotifywait -m /media/simc/ -e create
(also tried with moved-to but not related really)



Then made a file in the dir and...nothing. After some troubleshooting I found out that I have to create a file in it through the machine itself, whereas my usecase is I have this directory available on the network and will be moving files into it from other machines, which when I do does not seem to proc the output.



So using nano test gives me what I want:
/media/simc/ CREATE .test.swp
but when I move a file into the directory or create one in it from another machine, no dice.



What are my options?










share|improve this question







New contributor




user863492 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • If it helps any currently what I'm doing is I manually run a bash script that prompts the user to paste in the stuff in the file then mess with it a little and load it into the command (simcraft, for anyone curious). I'm trying to automate it more so I can just save the file into this directory and have the machine automagically grab the contents, mess with them and pass them on.

    – user863492
    32 mins ago














0












0








0








I have a dir called /media/simc/, I want to to set something up to monitor /media/simc/, and when a file is put in it (from this machine or any other on the network, it is a network mounted dir itself), I want to take that file and do stuff with it ("stuff", in this case meaning reading the contents and passing them to a command)
(I also want to exclude a specific filename from the watch, say notest.txt)



The issues are I do not know what this file is going to be named, but I do know one thing it is not going to be named that I need excluded, and I have zero clue what I'm doing generally.



I thought inotifywait was the answer after some googling, and set up a quick demo for myself with this just to test that it would see stuff I put in there and do...stuff
inotifywait -m /media/simc/ -e create
(also tried with moved-to but not related really)



Then made a file in the dir and...nothing. After some troubleshooting I found out that I have to create a file in it through the machine itself, whereas my usecase is I have this directory available on the network and will be moving files into it from other machines, which when I do does not seem to proc the output.



So using nano test gives me what I want:
/media/simc/ CREATE .test.swp
but when I move a file into the directory or create one in it from another machine, no dice.



What are my options?










share|improve this question







New contributor




user863492 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have a dir called /media/simc/, I want to to set something up to monitor /media/simc/, and when a file is put in it (from this machine or any other on the network, it is a network mounted dir itself), I want to take that file and do stuff with it ("stuff", in this case meaning reading the contents and passing them to a command)
(I also want to exclude a specific filename from the watch, say notest.txt)



The issues are I do not know what this file is going to be named, but I do know one thing it is not going to be named that I need excluded, and I have zero clue what I'm doing generally.



I thought inotifywait was the answer after some googling, and set up a quick demo for myself with this just to test that it would see stuff I put in there and do...stuff
inotifywait -m /media/simc/ -e create
(also tried with moved-to but not related really)



Then made a file in the dir and...nothing. After some troubleshooting I found out that I have to create a file in it through the machine itself, whereas my usecase is I have this directory available on the network and will be moving files into it from other machines, which when I do does not seem to proc the output.



So using nano test gives me what I want:
/media/simc/ CREATE .test.swp
but when I move a file into the directory or create one in it from another machine, no dice.



What are my options?







shell-script daemon inotify






share|improve this question







New contributor




user863492 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




user863492 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




user863492 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 34 mins ago









user863492user863492

1




1




New contributor




user863492 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user863492 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user863492 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • If it helps any currently what I'm doing is I manually run a bash script that prompts the user to paste in the stuff in the file then mess with it a little and load it into the command (simcraft, for anyone curious). I'm trying to automate it more so I can just save the file into this directory and have the machine automagically grab the contents, mess with them and pass them on.

    – user863492
    32 mins ago



















  • If it helps any currently what I'm doing is I manually run a bash script that prompts the user to paste in the stuff in the file then mess with it a little and load it into the command (simcraft, for anyone curious). I'm trying to automate it more so I can just save the file into this directory and have the machine automagically grab the contents, mess with them and pass them on.

    – user863492
    32 mins ago

















If it helps any currently what I'm doing is I manually run a bash script that prompts the user to paste in the stuff in the file then mess with it a little and load it into the command (simcraft, for anyone curious). I'm trying to automate it more so I can just save the file into this directory and have the machine automagically grab the contents, mess with them and pass them on.

– user863492
32 mins ago





If it helps any currently what I'm doing is I manually run a bash script that prompts the user to paste in the stuff in the file then mess with it a little and load it into the command (simcraft, for anyone curious). I'm trying to automate it more so I can just save the file into this directory and have the machine automagically grab the contents, mess with them and pass them on.

– user863492
32 mins ago










0






active

oldest

votes











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






user863492 is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f496944%2ffinding-a-way-to-wait-for-an-unknown-named-file-to-appear-in-a-directory-and-the%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








user863492 is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















user863492 is a new contributor. Be nice, and check out our Code of Conduct.













user863492 is a new contributor. Be nice, and check out our Code of Conduct.












user863492 is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f496944%2ffinding-a-way-to-wait-for-an-unknown-named-file-to-appear-in-a-directory-and-the%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Histoire des bourses de valeurs

Why is there Russian traffic in my log files?

Rename multiple files to decrement number in file name?