How to start inotifywait and another process from one shell script? [duplicate]

StackOverflow https://stackoverflow.com/questions/16678601

  •  30-05-2022
  •  | 
  •  

Вопрос

I'm trying to start a server process (storescp, from dicom toolkit) and a file system watcher (via inotifywait) from a shell script. Here's what I have so far.

#!/bin/bash

INFOLDER=/home/dicom/storescp_in/
OUTFOLDER=/home/dicom/dicom_jpeg

#watch the input directory
inotifywait -m -e close_write "$INFOLDER" | while read dicomfile
do
mv "$INFOLDER""dicomfile"  "$OUTFOLDER""$dicomfile"

done    

# start the storescp server
storescp -v -od $INFOLDER 104

But inotifywait appears to be a blocking call (sorry, i'm coming at this from a javascript event driven kind of experience; I don't have much experience with Bash scripts).. is it possible to start my server and inotifywait in the same script? how?

Это было полезно?

Решение

I solved it by using the & operator, like in question How do you run multiple programs in parallel from a bash script?

Seems to be just the thing!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top