Help with bash arrays and quotes (PvPGN)
I am trying to get PvPGN working... I have installed all the files, the only thing now is that bntrackd wants to use 'logs/bntrackd.log' for it's logfile, but seeing as it's in /usr/sbin, I want it to use /var/log/bntrackd. This is done with 'bntrackd --logfile=/var/log/bntrackd.log' but when I put that in the script it won't process it as a command (instead splitting it and complaining that I don't have --logfile=/var/log/bntrackd.log installed)
/etc/rc.d/pvpgn: Code:
#!/bin/bash Code:
PVPGN_DAEMONS=(bnetd d2cs d2dbs 'bntrackd --logfile=/var/log/bntrackd.log') |
Try to change
from [ -z "$PID" ] && /usr/sbin/$d to [ -z "$PID" ] && eval "/usr/sbin/$d" Single quotes or double quotes don't seem to import here. |
I don't think it's quite that simple. You're quoting of the array is pretty much correct. The problem is that the word splitting is being done here in the rc.d script:
Code:
for d in ${PVPGN_DAEMONS[@]}; do I thought you could probably simply embed a further set of escaped quotes or an escaped space when setting the array, but that doesn't seem to be working for me. What you really need is to modify the loop so that it handles the strings better. You could, for example, put quotes around the array like this: Code:
for d in "${PVPGN_DAEMONS[@]}"; do Code:
PID=`pidof -o %PPID /usr/sbin/${d% *}` |
Wow, thanks. Mega thanks. I might even try to get this sorted into a PKGBUILD and put on the AUR instead of the now defunct one there right now :)
Adding the quotes and the little extra bit for pidof worked. |
Glad to help.
Incidentally, I noticed one small thing that should be corrected. Please change the pidof command to: Code:
PID=`pidof -o %PPID /usr/sbin/${d%% *}` By the way, $(..) is generally recommended over `..` these days for embedded commands like the above, but I'll leave it up to you whether it's worth the effort fixing it in this script. |
All times are GMT -5. The time now is 12:38 PM. |