I am using the following script to watch a folder, and if the size changes and a file doesn't exist, it runs a script.
#!/usr/bin/sh SCRIPT="dim_import/xdir" while true; do size=$(du -s dim_import | cut -b 1-2) if [ $size -gt 32 ]; then if [ ! -f files ]; then $SCRIPT fi fi sleep 2 done
I run the script like so
The problem is that the script that gets run within the watcher program requires input. It echos out the prompt, but then the input is not sent to that script, but the the current shell. Thus if I input 1234 I get this:
sh: 1234: not found.
How can I make sure to send the input the correct place?
I have tried many different methods and none seem to work because of the unique way I am doing this. I am also open to better methods/work around. The script also has the ability to handle the input I want to send as an argument.
EDIT: I am trying to send a number like 62918
EDIT: I could also do something like this, but I get the same error:
SCRIPT="dim_import/xdir" while true; do size=$(du -s dim_import | cut -b 1-2) if [ $size -gt 32 ]; then if [ ! -f files ]; then echo "SR Number: "; read srNum $SCRIPT $srNum fi fi sleep 2 done
Note: I am not using Bash. I am using Sh.