Cut and paste getting my hair and make up "did". ;)
Point well taken.
;)
Bob Doolittle wrote:
Craig Bender wrote:
Bob D is 100% correct, utwho (or anything that invokes or could tie up
authd) can be dangerous. Can't stress this enough for custom kiosk
creation, though I understand that yours isn't in the kiosk script.
I'm a big believer in keeping things simple. There's really no reason
to use perl here.
While the following isn't "supported" because we don't guarantee that
the files in /tmp/SUNWut/config won't change, it works very nicely and
is a lot less "lines of code"
#!/bin/sh
MYDISP=`echo $DISPLAY | awk -F: '{print $2}' | awk -F. '{print $1}'`
MYTERM=`grep TERMINAL /tmp/SUNWut/config/dispinfo/$MYDISP | awk -F.
'{print $2}'`
/opt/SUNWut/bin/utwho -c |grep $MYTERM | awk '{print $4}'
That could be simplified as well for less invocations of awk/grep. With
respect, Craig, there's never an excuse for more than one invocation of
sed/awk/grep on the same input string. It's inefficient and unnecessary.
To get IP address, I would simplify your script as follows:
MYDISP=`echo $DISPLAY | awk -F: '{ split($2,a,"."); print a[1] }'`
MYTERM=`awk -F. '/^TERMINAL_ID=/ {print $2}'
/tmp/SUNWut/config/dispinfo/$MYDISP`
/opt/SUNWut/bin/utwho -c | awk "/${MYTERM}\$/ { print \$4 }"
Also note the additional pattern constraint anchors on the 2nd and 3rd
lines. That might help future-proof this approach somewhat.
Sorry - I just couldn't resist :-)
-Bob
CJ Keist wrote:
Murray, Thank you!
Thanks for all the replies. I did get my script working by
verifying the user name field from the utwho output first. If I
couldn't find the prefix of my kiosk account then adjust my array
index accordingly.
But this script is what I think I'm looking for, thanks for this
sample Code! I don't think I need to worry about overloading the
utauthd, as this script wouldn't be called at a kiosk session start
up but only when a user sits down and selects what desktop
environment they want to work in.
On 8/2/10 8:38 PM, Murray Fraser wrote:
#!/usr/bin/perl
my $line;
my $key;
my $value;
my $ipaddr;
my $token;
my $mytoken = $ENV{SUN_SUNRAY_TOKEN};
open (UTNETPIPE, "echo 'status'|/etc/opt/SUNWut/basedir/lib/utnetpipe
0.0.0.0 7010 |");
while(<UTNETPIPE>) {
chomp;
$line = $_;
if ($line eq "end"&& $token eq $mytoken) {
printf "My token: $token\n";
printf "My IP: $ipaddr\n";
break;
}
($key, $value) = split('=', $line, 2);
if ($key eq "terminalIPA") { $ipaddr = $value };
if ($key eq "tokenName") { $token = $value };
}
On Tue, Aug 3, 2010 at 11:40 AM, Murray Fraser<msfra...@gmail.com>
wrote:
utwho is a script as well, have a read of /opt/SUNWut/bin/utwho
essentially, if you open a tcp socket to port 7010, and send 'status',
you will get all the information you need, and a lot more.
You can use perl to put it all together (each record is between a
'begin' and 'end' line). I think you want the 'terminalIPA' line for
the ip address, and 'connected=true' for connected.
On Tue, Aug 3, 2010 at 1:21 AM, CJ Keist<cj.ke...@colostate.edu>
wrote:
I'm currently trying to figure out the correct IP address for the
DTU using
the following perl script:
#!/usr/bin/perl
my $line;
my @array;
my $ip;
my $junk;
my $user = $ENV{USER};
open(WHO, "/opt/SUNWut/bin/utwho -c|");
open(LOG, ">>/tmp/log.txt");
while (<WHO>) {
$line = $_;
@array = split (' +\s', $line, 5);
print LOG "User: $user $array[1]\n";
if ($user eq $array[1]) {
($ip, $junk) = split(' ', $array[2], 2);
print LOG "IP: $ip\n";
if ($ip =~ "192.168") {
system("/opt/SUNWut/bin/utswitch -h 192.168.100.12");
}
else {
system("/opt/SUNWut/bin/utswitch -h
sunfire5.engr.colostate.edu");
}
break;
}
}
close(WHO);
close(LOG);
The problem I'm running into is the case with the following two
utwho -c out
lines:
2.0 pseudo.00144f946d3e engr85 192.168.102.208
P8-FS.00144f946d3e
10.0 pseudo.00144fd18d32 engr48 129.82.229.249
P8-FS.00144fd18d32
The space in the beginning of the first utwho output is throwing
my whole
split return in the dumps. Just wonder if there is a better way
in getting
the IP of the DTU you are on when running in kiosk mode? Is the an
environment variable set for the IP of the DTU?
--
C. J. Keist Email: cj.ke...@colostate.edu
UNIX/Network Manager Phone: 970-491-0630
Engineering Network Services Fax: 970-491-5569
College of Engineering, CSU
Ft. Collins, CO 80523-1301
All I want is a chance to prove 'Money can't buy happiness'
_______________________________________________
SunRay-Users mailing list
SunRay-Users@filibeto.org
http://www.filibeto.org/mailman/listinfo/sunray-users
_______________________________________________
SunRay-Users mailing list
SunRay-Users@filibeto.org
http://www.filibeto.org/mailman/listinfo/sunray-users
_______________________________________________
SunRay-Users mailing list
SunRay-Users@filibeto.org
http://www.filibeto.org/mailman/listinfo/sunray-users
_______________________________________________
SunRay-Users mailing list
SunRay-Users@filibeto.org
http://www.filibeto.org/mailman/listinfo/sunray-users
_______________________________________________
SunRay-Users mailing list
SunRay-Users@filibeto.org
http://www.filibeto.org/mailman/listinfo/sunray-users