Email: bknpk@hotmail.com Phone: +972-54-7649119





Explain, by example, my aliases for operating screen command.

  1. This page explains some of my aliases, which help in operating the screen command. Motivation, for alias description, as well as some other nice aliases are explained at the following page

  2. Screen opens a virtual terminal. I use it mainly to replace a VNC. I open terminals, than hang up and later re-connect, in some cases, from a different computer at a different location. Terminals are less demanding in system CPU and memory as well as in bandwidth. When it comes to work from remote, this is important. Terminals are low resources consumers, compared with VNC.
    Since I frequently use screen command:

    Be it for torrent text programs, which I want to access from remote and locally at home too.
    Sometimes, at work, I start a long simulation and I need to follow up its progress from home, so screen is the best option in town, started at work and later continued from home.
    If the opposite is the case, than screen contribution is much higher. If I start a long test at home and later disconnect the program may stop, once I log out from the office remote computer.
    Although, I suggest in this site another way to run a long program, disconnect and later connect from a different location without stopping the program, using cron, screen is extremely simple relatively.

  3. So I need to quickly find out what screens are active, simply to attach or de-attach to any one of them.
    Last, but not least, is control A, which is used as a prefix to special screen characters. This is not convenient, when using a simple x terminal, as control A is used to move the cursor to line start.



  4. #screen
    #attach to an existing screen,
    #replace control A with control N (if multiple screens are used, use -S name for screen),
    #list all existing screens

    alias scrat 'screen -d -r'
    alias scrst 'screen -e^Nn'
    alias scrls 'screen -ls'
    alias scrpl 'perl /home/pini/bin/scr_top.pl '


  5. The last alias calls a PERL script. The script, if invoked without parameters, simply does a screen -ls command to list all available screens and their status. It also numbers them, so if a number is given the script will attach to the corresponding screen.
    The script is short as shown below:

    #!/bin/perl

    $cmd="screen -ls";
    $dis=`$cmd`;
    @lines=split("\n", $dis);
    $i=0;
    foreach $j ( @lines ) {
      #new more general
      if($j =~ /([0-9]*\.[a-zA-Z_]*.*Detached)/) {
        $scr=$1; chomp($scr);
        print("$scr -> $i ($ARGV[0])\n");
        if($ARGV[0] == $i && $ARGV[0] ne "") {
          if($scr =~ /([0-9]*\.[a-zA-Z_0-9]*).*/) {
            $scr=$1;
            $cmd="screen -d -r " . $scr;
            print("$cmd ($ARGV[0] $i)\n");
            system($cmd);
          }
          exit(0);
        }
        $i++;
      }
    }




V

 


Home

Run a program till its license is available






Search This Site


Feedback This Site




new pages on this site