A wrapper for screen to deal with user issues
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.4 KiB

  1. #!/bin/bash
  2. # Simple script to try catch common errors with screen
  3. # Andrew Harford <receive@redbrick.dcu.ie>
  4. # November 2008
  5. PATH=/bin:/usr/bin
  6. if [ ! -z "$1" ]; then
  7. # If the user has supplied arguments run screen with those arguments
  8. exec screen "$*"
  9. else
  10. # Otherwise, work out if they're running screen.
  11. # If they're running screen already, lets give a warning
  12. if screen -ls | grep -q "No Sockets"; then
  13. echo "==============================================================================";
  14. # Find out if they are running inside screen
  15. if [ ! -z "$STY" ]; then
  16. echo "You are attempting to run screen from within screen."
  17. echo "You probably don't want to do this."
  18. else
  19. # Otherwise, the screen is detached. user probably wants to re-attach.
  20. echo "You are attempting to open a new screen session, even though you have an"
  21. echo "existing session running. You probably don't want to do this."
  22. echo
  23. echo "To continue your existing session run screen -DR"
  24. fi
  25. echo
  26. echo "You can read more about screen on http://wiki.redbrick.dcu.ie/mw/Screen"
  27. echo "To override this message and run another screen use $(which screen)"
  28. echo "=============================================================================="
  29. exit 1
  30. else
  31. # if we get this far then just open a new screen
  32. exec screen
  33. fi
  34. fi