On Sat, Sep 28, 2019 at 07:13:32AM +0200, Jean-Philippe MENGUAL wrote: > > You might want to check by adding this part to your script (before the > > part "echo CTRL+C to..."): > > > > proc=`fuser /dev/dsp| awk "{print $2}"` > > if [ -n ${proc+x} ]; then > > ps auxww | awk '($2 == '$proc'){print $0}' > > else > > echo "no process is obtaining /dev/dsp" > > fi > > > > and it will print which process is obtaining the /dev/dsp > > hmmm I get: > awk: line 1: syntax error at or near )
Yeah, the quoting is rather messed up there. In fact, the whole command is rather suspect, for several reasons. Best to discard it. I believe the intent was to do something like this: if pids=$(fuser /dev/dsp 2>/dev/null); then echo "the following processes are using /dev/dsp:" for pid in $pids; do ps -o pid= -o args= -p "$pid" done else echo "no processes are using /dev/dsp" fi One may adjust the ps -o options as desired. (I wrote this for sh, not bash. Had I written it for bash, I would have used arrays and a dynamically generated single ps command, instead of an unquoted list-in-a-string and multiple ps commands.)