One of my friends was looking for a mechanism to invoke a script as another user AND pass in a parameter.
Challenge, accepted :-)
/home/db2inst1/foobar.sh
#!/bin/bash
echo "Hello World! from `whoami`"
echo "And today's special is " $1 "!!! "
exit
and here's how I invoke it from another user ( root ): -
su - db2inst1 -c '/home/db2inst1/foobar.sh Fish'
Hello World! from db2inst1
And today's special is Fish !!!
su - db2inst1 -c "/home/db2inst1/foobar.sh Beef"
Hello World! from db2inst1
And today's special is Beef !!!
Bottom line, wrap the remote command in single or double quotes, with the parameter passed after the name of the script.