Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Set X11 authority file hostname via a script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Set X11 authority file hostname via a script
Authored by: TokyoJimu on Apr 28, '04 02:02:30AM
I suspect the script was mangled by HTML. I get an error on the line

$_=;
I also get a warnng:
Name "main::IN" used only once: possible typo at bin/xupdate line 7.

And $hostnamen should be $hostname I presume.

I can't get it working in any case.

[ Reply to This | # ]

Set X11 authority file hostname via a script
Authored by: Orj on Apr 28, '04 04:34:24AM

Sorry, this was my first posting, and my script got completely scrambled by the html interpreter that ate all backslashes (\). Here is a plain text version which looks better:

#!/usr/bin/perl -w
# Usage: resetXauth
# updates the ~\.Xauthority for changed hostname (eg for mobile connections)
# possible BUG: not sure this works for any xauth method; tested only with
# MIT-MAGIC-COOKIE on a unix system (actually Mac OSX 10.3)

$hostname=`hostname`;
chomp $hostname;
$xauthority=$ENV{'HOME'}.'/.Xauthority';
undef $/; # read the whole file in a variable
open IN,$xauthority;
$_=<IN>;
s/^\x01\x00\x00\x0d([^\x00]+)/\x01\x00\x00\x0d$hostname/;
print "Old hostname in ~/.Xauthority was $1, replaced by $hostname\n";
rename $xauthority, "$xauthority.back";
open OUT, ">$xauthority";
print OUT;
exit;

---
In theory, theory and practice are the same. In practice, they're not.



[ Reply to This | # ]