Variable substitution for logged in user for action, possible?

I wrote a cgi-bin program in bash (but you could do this in whatever language). Then setup an action (Global Settings -> Custom icon and actions) a show in column one… with something like:

https://somehost.example.com/cgi-bin/rdp?host=$HOSTNAME$&user=$USER_ID$

#!/bin/bash
# The cgi-bin/rdp program

# REQUEST_URI look like /cgi-bin/rdp?host=hostname&user=username

rdphost=`echo "$REQUEST_URI" | sed -n 's,.*[?&]host=\([A-Za-z0-9-][A-Za-z0-9-]*\).*,\1,p'`
rdpuser=`echo "$REQUEST_URI" | sed -n 's,.*[?&]user=\([A-Za-z0-9-][A-Za-z0-9-]*\).*,\1,p'`
rdpdomain=EXAMPLE
rdpfulldomain=example.com

if [ "$rdphost" ]; then
  cat <<HERE
Content-type: application/rdp
Content-disposition: attachment;filename=${rdphost}.rdp

redirectclipboard:i:1
redirectposdevices:i:0
redirectprinters:i:1
redirectcomports:i:1
full address:s:${rdphost}.${rdpfulldomain}
username:s:${rdpuser}
domain:s:${rdpdomain}
HERE
fi
4 Likes