I'm running a script as root. Within that script I want to run a single command as the person logged in, which usually is not root. The single command slaps a conky display item on the user's desktop.
The problem is the conky braces and parentheses that need to be passed as actual characters and not shell symbols. I've unsuccessfully tried various methods of backslashes and the like to properly pass the command.
In the script I want to run:
Code:
su - `logname` -c conky -t '${color green}'$DRIVEMODEL'('${BACKUPDISK:5:3}') Temp:${color white} ${hddtemp '$BACKUPDISK'}' -x 280 -y 297 &>/dev/null
Where:
DRIVEMODEL=WDK7500AAKS
BACKUPDISK=/dev/sdb
When I try running the complete command I receive "bad substitution" error messages. The error message makes sense to me and I understand what is happening. Yet I am struggling with the syntax I need to run the complete command.
By itself the conky command runs fine from the command line or from within my script, but not in conjunction with the
su command.
Of course, I cannot split the su and conky command because the moment I su as a different user, the script terminates. I need to run both commands together.
The challenge is the su command requires the text following the
-c option be enclosed in single or double quotation marks, otherwise the su command stops reading the text after the first space. When I enclose the entire conky portion in double quotation marks, I receive the shell error messages.
I appreciate help. As always, thanks.