what other bash variables are available during execution such as $USER that can assist on my script?

Posted by semi-newbie on Ask Ubuntu See other posts from Ask Ubuntu or by semi-newbie
Published on 2011-01-11T01:11:00Z Indexed on 2011/01/11 1:59 UTC
Read the original article Hit count: 206

This is related to question 19245, in that one of the responders answered the question in an awesome way, and very VERY clear to any newbie. Now here is a question that i can't seem to figure.

i wrote a script for starting the vmware firefox plugin (don't worry. i gave that up and now run vBox VERY happily. i left vmware for my servers :) )

I needed to start the plugin as sudo, but i also needed to pass an argument (password) to it, that happen to be the same.

So, if my password was Hello123, the command would be: sudo ./myscript.sh hi other Hello123

running from command line, the script would ask for my sudo password and then run. i wanted to capture THAT password and pass it as well. i also wanted to run graphically, so i tried gksudo, and there is an option -p that returns the password for variable assignment.

well, that was a nightmare, because i would still get prompted for the original sudo: see below Find UserName

vUser=$USER Find password (and hopefully enable sudo)

vP=gksudo -p -D somedescriptiontext echo Execute command

gksudo ./myscript.sh hi $vUser $vP

and i still get prompted twice.

so my question is tri-fold:

  1. is there a variable i can use for the password, just like there is one for user, $USER?

  2. is there a different way i should be assigning the value resulting of the command i have in $vP? i am wondering if executing the way i have it, does it in an uninitiated session and not the current one, since i am getting some addtl warning type errors on some variables blah blah

  3. i tried using Zenity to just capture the text, but then of course, i couldn't pass that value to sudo, so i could only use as a parameter, which puts me back in 2 prompts.

Thanksssssssssss!

© Ask Ubuntu or respective owner

Related posts about ubuntu-desktop

Related posts about bash