I'm trying to create mozilla profile for another user from command line using su.

When I'm trying from X, this will work.

su myuser -c 'mozilla -CreateProfile newprofile'

But my goal is to embed this to a script and it will execute only in command line mode. If I try this, from a command line, It also works:

DISPLAY=1.0 mozilla -CreateProfile newprofile

The question is how to embed "DISPLAY" variable in "su" command, cause this fails:

su myuser -c 'DISPLAY=1.0 mozilla -CreateProfile newprofile'
link|improve this question

29% accept rate
Why is "linux" in the title if you say you are running SCO Unix? – grawity Sep 8 '10 at 21:09
feedback

migrated from stackoverflow.com Sep 8 '10 at 12:43

This question came from our site for professional and enthusiast programmers.

5 Answers

Have you tried this:

su myuser -c 'export DISPLAY=\"1.0\"; mozilla -CreateProfile newprofile'

This should really be posted on superuser.com

Try that variant by escaping the quotes in the variable DISPLAY...

link|improve this answer
Yes, I've tryed it. It fails too. – Anonymous Sep 8 '10 at 12:38
feedback

This works for me:

su sh -c 'DISPLAY=1.0  echo $DISPLAY'

what exactly is the error you are getting?

link|improve this answer
Unfortunately, this doesn't work for me. Maybe becouse of my OS - SCO Unix. Errors are only some perl warnings from 'locale', but I've got them also in X mode, so this is not the reason. Mozilla comand finishes, but without creating the profile. – user48777 Sep 8 '10 at 12:45
1  
SCO Unix? Respect. – Janne Pikkarainen Sep 8 '10 at 12:49
feedback

What about this one:

su myuser -c "sh -c 'DISPLAY=1.0 mozilla -CreateProfile newprofile'"
link|improve this answer
No it fails too. – user48777 Sep 8 '10 at 14:15
And what does complain? – cYrus Sep 8 '10 at 14:17
It does not complain. it finishes cleanly, but profile directory is not created. Never mind, I solved the problem. Thanks for reply. – user48777 Sep 8 '10 at 14:45
feedback

Solved:

su - -c 'DISPLAY=1.0 mozilla -CreateProfile newprofile' myuser
link|improve this answer
feedback
TEMPXAUTH=$(xauth nlist) su -c 'xauth nmerge <<< "$TEMPXAUTH" && mozilla -CreateProfile newprofile'

A temporary file would work too.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.