#!/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 <[email protected]> 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 <[email protected]> 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: [email protected]
>> 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
>> [email protected]
>> http://www.filibeto.org/mailman/listinfo/sunray-users
>>
>
_______________________________________________
SunRay-Users mailing list
[email protected]
http://www.filibeto.org/mailman/listinfo/sunray-users