version 1.5, 2025/02/01 03:17:46
|
version 1.7, 2025/03/10 15:31:54
|
Line 10
|
Line 10
|
# |
# |
# Licensed AGPL-3.0 |
# Licensed AGPL-3.0 |
# |
# |
|
# |
# $Log$ |
# $Log$ |
|
# Revision 1.7 2025/03/10 15:31:54 snw |
|
# Test |
|
# |
|
# Revision 1.6 2025/02/04 18:55:12 snw |
|
# Updates |
|
# |
# Revision 1.5 2025/02/01 03:17:46 snw |
# Revision 1.5 2025/02/01 03:17:46 snw |
# Fix session list |
# Fix session list |
# |
# |
Line 33 use JSON;
|
Line 40 use JSON;
|
use Data::Dumper; |
use Data::Dumper; |
use Term::ReadKey; |
use Term::ReadKey; |
use Getopt::Long; |
use Getopt::Long; |
|
use Text::Glob qw(match_glob); |
|
|
my $sso_account = ''; |
my $sso_account = ''; |
my $apikey = ''; |
my $apikey = ''; |
Line 251 sub send_im {
|
Line 259 sub send_im {
|
} |
} |
|
|
sub ls { |
sub ls { |
my ($description, @entries) = @_; |
my ($description, $match, @entries) = @_; |
|
|
|
if($match eq "") { |
|
$match = '*'; |
|
} |
|
|
|
print "Directory of [$description] matching \'$match\':\n\n"; |
|
|
my @sorted = sort(@entries); |
my @sorted = sort(@entries); |
my $maxlen = 0; |
my $maxlen = 0; |
|
|
foreach my $entry (@sorted) { |
foreach my $entry (@sorted) { |
my $len = length($entry); |
my $len = length($entry); |
if ($len > $maxlen) { |
if ($len > $maxlen) { |
$maxlen = $len; |
$maxlen = $len; |
} |
} |
} |
} |
|
|
$maxlen = $maxlen + 2; |
$maxlen = $maxlen + 2; |
|
|
my $ct = $#sorted + 1; |
my $ct = $#sorted + 1; |
foreach my $entry (@sorted) { |
foreach my $entry (@sorted) { |
if($col + $maxlen >= $wchar) { |
if(match_glob($match, $entry)) { |
print "\n"; |
if($col + $maxlen >= $wchar) { |
$col = 0; |
print "$entry\n"; |
|
$col = 0; |
|
} |
|
else { |
|
printf("%-$maxlen\s", $entry); |
|
$col = $col + $maxlen; |
|
} |
} |
} |
else { |
else { |
printf("%-$maxlen\s", $entry); |
$ct = $ct - 1; |
$col = $col + $maxlen; |
} |
} |
} |
} |
|
print "\n$ct items in $description\n"; |
|
|
|
|
print "\n\n$ct matching items in directory\n"; |
} |
} |
|
|
sub prompt { |
sub prompt { |
Line 422 sub prompt {
|
Line 444 sub prompt {
|
@path = @oldpath; |
@path = @oldpath; |
} |
} |
else { |
else { |
$mode = "SSO"; |
$mode = "RAS"; |
@path = ('sso', $user); |
@path = ('ras', $user); |
} |
} |
} |
} |
else { |
else { |
Line 489 sub prompt {
|
Line 511 sub prompt {
|
print "sessions: must be in ras mode\n"; |
print "sessions: must be in ras mode\n"; |
} |
} |
else { |
else { |
ls "active RAS sessions", list_ras_sessions(); |
if($cmd[1]) { |
|
ls "active RAS sessions", $cmd[1], list_ras_sessions(); |
|
} |
|
else { |
|
ls "active RAS sessions", '*', list_ras_sessions(); |
|
} |
} |
} |
} |
} |
elsif ($cmd[0] eq "lssn") { |
elsif ($cmd[0] eq "lssn") { |
Line 498 sub prompt {
|
Line 525 sub prompt {
|
} |
} |
else { |
else { |
my @sns = list_ras_screennames($user); |
my @sns = list_ras_screennames($user); |
ls "RAS screen names for $user", @sns; |
if($cmd[1]) { |
|
ls "RAS screen names for $user", $match, @sns; |
|
} |
|
else { |
|
ls "RAS screen names for $user", '*', @sns; |
|
} |
} |
} |
} |
} |
elsif ($cmd[0] eq "ls") { |
elsif ($cmd[0] eq "ls") { |
Line 530 sub prompt {
|
Line 562 sub prompt {
|
my $col = 0; |
my $col = 0; |
my $pstr = join('/', @path); |
my $pstr = join('/', @path); |
my $pfin = "/$pstr"; |
my $pfin = "/$pstr"; |
ls $pfin, @entries; |
if($cmd[1]) { |
|
ls $pfin, $cmd[1], @entries; |
|
} |
|
else { |
|
ls $pfin, '*', @entries; |
|
} |
} |
} |
|
|
} |
} |