Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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'
share|improve this question

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

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

    
Why is "linux" in the title if you say you are running SCO Unix? –  grawity Sep 8 '10 at 21:09
add comment

5 Answers

TEMPXAUTH=$(xauth nlist) su -c 'xauth nmerge <<< "$TEMPXAUTH" && mozilla -CreateProfile newprofile'

A temporary file would work too.

share|improve this answer
add comment

Solved:

su - -c 'DISPLAY=1.0 mozilla -CreateProfile newprofile' myuser
share|improve this answer
add comment

What about this one:

su myuser -c "sh -c 'DISPLAY=1.0 mozilla -CreateProfile newprofile'"
share|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
add comment

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...

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

This works for me:

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

what exactly is the error you are getting?

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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