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
>watcher &
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.
sleep 60 & jobs -l
, you see nothing? – user3188445 Jul 17 '15 at 16:45jobs -l
only works if you are in the same shell. That is why it was showing nothing. – James Jul 17 '15 at 18:03screen
ortmux
to run it in a virtual terminal. – Barmar Jul 17 '15 at 18:26whereis
command, it doesn't find them because they do not exist on the system. I am not using Bash. – James Jul 17 '15 at 19:07