Register
It is currently Thu Oct 30, 2014 10:50 pm

Assigning output of xauth to variable


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Mon Oct 12, 2009 12:49 pm   

Joined: Mon Oct 12, 2009 12:41 pm
Posts: 1
Newbie basher question:

I'd like to assign the output of the following line to a shell script variable:
'xauth list :0'

For background, here are the steps I type into a terminal that I'm trying to put in a bash file:

xauth list :0
(the output shows the current unix:0 MIT-MAGIC-COOKIE-1 value: e95ea........47a, which I then add to xauth)
xauth add :0 MIT-MAGIC-COOKIE-1 e95ea.......47a
export DISPLAY=:0
java -jar selenium-server.jar

Any ideas on how to send the output of 'xauth list :0' to a variable?

Thanks
Samtediou


Top
 Profile  
 PostPosted: Mon Oct 12, 2009 3:53 pm   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
depends abit on what type of output is given from xauth, but i would try this:
Code:
var=$(xauth list :0)


It's standard "executing programs in a variable"-bash syntax :) also you can use "backticks" which is done like this:
Code:
var=`xauth list :0`


Both does the same in bash, but the $() is easier to read IMHO.

Best regards
Fredrik Eriksson


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP