Screen

Displaying Salesforce Test Status in screen using JSforce

by Patrick Connelly posted on September 29, 2014

This post will probably only be useful to one other person out there, but it was a fun exercise and thought I’d at least share my output.

One of the biggest challenges I have when running tests is that I will often forget they are running and leave them completed for a while before I go back and remember I ran them. This mainly happens when I’m running an entire class worth of tests and have 5-10 minutes to kill. When first learned about JSforce and it’s cli capability I was in love! So I set out to make it so that the current testing status is displayed inside of my screen session. At the end of it all this is what I came up with:

Screen status


External programs that update screen

by Patrick Connelly posted on September 18, 2009

Screen is a great tool, and it allows you do to alot of neat things. One of my favorites is binding commands to key strokes. So all you have to do is hit F5 and it will start something in the background. Such as a build command. The problem is, you either get no output, or you get spam all over your screen. Well I’ve finally found a way around that. The answer lies in ANSI Privacy Messages.

In your .screenrc, make sure you have a place that will show messages. If you start up screen and you see “New screen…” then you’ve got this. Next add your script to your .screenrc

bind -k k5 exec /home/pcon/bin/build_script.sh

Now everything in your screen is ready to go. Now, on to build_script.sh

#!/bin/bash

echo -n -e "\033^Starting Build\033\\"

# Do something here

echo -n -e "\033^Ending Build\033\\"

That’s it. Now your screen will display “Starting Build” and “Ending Build” on your display. If the stuff in between happens too fast, you may only see your last message. The key thing is that your message has to start with \033^ and end with \033\\ otherwise you’ll lose your cursor. And you have to have the -e on the echo so that it will interpret the octal codes correctly.


Perpetual Screen Part Deux

by Patrick Connelly posted on February 02, 2009

So, I’ve figured out how to add in a “fail-safe” to the perpetual screen, so that if you want to ssh without starting screen you can. And it’s pretty easy. First add the following to your sshd_config and restart ssh

AcceptEnv NO_SCREEN

Then add the following to the bottom of you .bashrc: (Note: I named my screen ‘main’ you can name yours whatever you want)

NO_SCREEN=`echo "."$NO_SCREEN`
# Hack to get around if the variable is not set

if [ $TERM = "screen" ]
# If we are already in a screen do nothing
then
     echo -n ""
elif [ $TERM = "dumb" ]
# If we are using scp do nothing
then
     echo -n ""
elif [ $NO_SCREEN = ".true" ]
# Our fail safe to ssh w/o screen
then
     echo -n ""
else
# Startup screen
     screen -Rd main && exit
fi

Then, you can either ssh like normal to start the screen, or do the following to login without screen starting

export NO_SCREEN="true"

ssh -o "SendEnv NO_SCREEN" user@host

Works like a champ


Perpetual Screen

by Patrick Connelly posted on December 29, 2008

This article has been updated

So, I’ve been tossing around the idea for the past while to make is so that screen starts up every time I ssh into my box at the house. Well, I finally broke down and did it, and it wasn’t that bad at all. I’ve named my screen session main you can call it whatever you want. Just add the following to the end or your .bashrc If you don’t put it at the end, you the rest of your .bashrc won’t get evaluated.

if [ $TERM == "screen" ]
# If we are already in a screen do nothing
then
  echo -n ""
elif [ $TERM == "dumb" ]
# If we are using scp do nothing
then
  echo -n ""
else
# Startup screen
  screen -Rd main && exit
fi

It works so far with everything I’ve had to do, but we’ll see if I run across any other problems.