James –

 

You should be able to use $REMOTE_USER in the command that is being executed in Webmin  I’ve done this in USermin. I assume it’s the same in Webmin. 

 

So, in the the webmin command configuration for the command I you would put:

 

/home/user/scripts/id-test.sh $REMOTE_USER

 

 

Then, in your script, you would have USER=$1  (or whatever the syntax is in bash to get the first argument)

 

Like I said, I’ve done this in Usermin, but it should work similarly in Webmin.

 

-LLBrian

 

 

 

From: Johnson, James A [mailto:J1Johnson@unum.com]
Sent: Wednesday, June 12, 2013 9:55 PM
To: webadmin-list@lists.sourceforge.net
Subject: [webmin-l] Problems with passing $REMOTE_USER

 

I’m trying to execute a bash script through webmin and have the current webmin users login name be passed to the script. I’ve googled a bit and found that $REMOTE_USER is the environmental variable that should pass that information to the script but it’s not working.

 

Here’s the script:

 

#!/bin/bash

 

USER=$REMOTE_USER

 

echo ""

echo "The user executing this script is $USER"

echo ""

 

exit 0;

 

The result when I execute the script is:

 

Output from ssh -l user linuxserver /home/user/scripts/id-test.sh ..

Authentication successful.

 

The user executing this script is

 

I feel pretty stupid that I can’t make this work. I’ve also tried running the script like this:

 

ssh -l user linuxserver /home/user/scripts/id-test.sh $REMOTE_USER

 

And having the script read in $1 but it’s still not passing.

 

Any assistance would be appreciated … thanks!

 

- Jim