Skip to content
Snippets Groups Projects
Select Git revision
  • 65d85a9bbb0fbb9f6245544e41d7ea90718fd2c7
  • main default protected
2 results

HFS_Wrapper.m

Blame
  • SLS 7.12 KiB
    #!/usr/bin/perl
    #
    # find or create screen session
    #
    # $Id: SLS,v 1.3 2012/12/14 13:35:38 gonter Exp $
    #
    
    =pod
    
    =head1 USAGE
    
      SLS [-opts] [session]
    
    =head1 DESCRIPTION
    
    reattach or create screen which matches given session name
    
    =head1 SYNOPSIS
    
      SLS mistkisten
    
    ... reattaches or creates a screen called "mistkisten"
    
      SLS mistk
    
    ... reattaches the screen called "mistkisten" which was created earlier (or otherwise it creates a screen called "mistk")
    
    =head1 Options
    
     -P ... supress process listin
     -n ... do not actually perform screen command
     -c ... create new session even if one matches
     -t ... print entire process tree for a given screen session
    
    =cut
    
    use strict;
    
    use Data::Dumper;
    $Data::Dumper::Indent= 1;
    
    my $print_tree= 0;  # 0 print only last command; 1 print all commands in the tree
    my $create= 0;
    my $doit= 1;
    my $list_processes= 1;
    my $debug= 0;
    
    my @PARS= ();
    PARS: while (defined (my $arg= shift (@ARGV)))
    {
      if ($arg =~ /^-/)
      {
        if ($arg eq '--') { push (@PARS, @ARGV); last PARS; }
        elsif ($arg eq '-c') { $create= 1; }
        elsif ($arg eq '-n') { $doit= 0; }
        elsif ($arg eq '-P') { $list_processes= 0; }
        elsif ($arg eq '-t') { $print_tree= 1; }
        elsif ($arg =~ /^-(D+)/) { $debug += length ($1); }
        else { &usage (); exit (0); }
      }
      else
      {
        push (@PARS, $arg);
      }
    }
    
    my $S= &screen_ls ();
    ## print Dumper ($S);
    
    my $hostname= &get_hostname ();