# screen /var/run/utmp: No such file or directory Cannot find termcap entry for '...'

QNAP screen command broken-ness

On the QNAP per default the screen command is not configured properly. When running screen the following errors are output.

# screen
/var/run/utmp: No such file or directory
Cannot find termcap entry for '...'

(Where ... is a placeholder for xterm-color, xterm-256color or any file which is not available on the QNAP.)

If you cd to /var/run/ you will notice that the file utmp is indeed missing. To solve the first error it suffices to create an empty file.

# touch /var/run/utmp

The second error appears because the termcap to which the environment variable TERM points, is missing. You can verify this with checking your TERM environment variable:

# export | grep xterm

You will notice the TERM variable is defined and as such pointing to a file, which is not there. If you browse to the following directory you can verify that:

# ls /usr/share/terminfo/x/

Per default there are only two entries: xterm and xterm-xfree86. xterm-xfree86 is the successor of the original xterm-color. Screen is searching for a specific xterm-file which is configured on the terminal from which you are controlling your QNAP. If you use a MAC for example, the default terminal preferences declare the terminal as xterm-256color. This means that when you connect with your MAC to the QNAP, it will inform the QNAP of the declared terminal and as such screen on the QNAP fails to work, if it cannot find the requested xterm-file.


Knowing this gives you a few options for solving this:

  • Changing the terminal preferences to use xterm.
  • Make sure the TERM environment variable on your QNAP is pointing to xterm-xfree86.
  • Create one or more symbolic links from the requested xterm file to xterm-xfree86.


The last solution with the symbolic links will be a general solution that will probably work in most of the cases. Changing a file name would be also an option but gives less flexibility. Create one or more symbolic links from the missing file (xterm-256color, xterm-color or ...) to its successor xterm-xfree86.

But...

Once you have modified your QNAP and restarted it, you may find all settings are lost. So how to make this persistent?

See Automatic startup ... when system boots for tips on keeping settings and software persistent.

Depending on your model, mount the ramblock (Note that this is device dependent, check the link above. For example for the TS-459 and TS-469 it is /dev/sdx6):

mount -t ext2 /dev/sdx6 /tmp/config
vi /tmp/config/autorun.sh

Add the following lines:

#!/bin/sh
# start a single script
/share/MD0_DATA/custom/autorunmaster.sh
# finish

Ensure that /tmp/config/autorun.sh is executable:

chmod +x /tmp/config/autorun.sh

Then unmount with:

umount /tmp/config

Now create a directory:

mkdir /share/MD0_DATA/custom/

Edit the file autorunmaster.sh

vi /share/MD0_DATA/custom/autorunmaster.sh

Add or enter the following:

#!/bin/sh
# This is the autorunmaster file which is executed from
# mounted device /dev/sdx6/ with file autorun.sh
# Enter below your scripts and comments
#
# Fix broken screen command which has missing file
# /var/run/utmp and may have missing environment
# variables for TERM, as such pointing to a non-existing
# xterm file like xterm-color.
touch /var/run/utmp
ln -s /usr/share/terminfo/x/xterm-xfree86 /usr/share/terminfo/x/xterm-256color
ln -s /usr/share/terminfo/x/xterm-xfree86 /usr/share/terminfo/x/xterm-color

And make sure that autorunmaster.sh is executable:

chmod +x /share/MD0_DATA/custom/autorunmaster.sh

Troubleshooting

  • Message 'Aborted because of window size change' appears. Disable remote-controlled terminal resizing, which is in Putty in Terminal -> Features
  • If /share/MD0_DATA does not exist you may need to use  /share/HDA_DATA instead depending on your disk configuration

Alternative solution

If for some reason the above mentioned does not work, the following might. Run the screen command with an exported variable:

# TERMINFO='/usr/share/terminfo/' screen

or

# export TERMINFO='/usr/share/terminfo/'
# screen

To make this setting permanent, you can add this to your .profile, before the 'reset' line

export PS1='[\w] # '
export TERMINFO='/usr/share/terminfo/'
reset

This assumes that you are using the default QNAP shell of /bin/sh. If you are using /bin/bash, put the export command in .bashrc.

Troubleshooting

  • If the .profile gets overwritten at reboot (which is the case with firmware 3.8.1) a workaround could be to create a .profile_backup in /share/HDA_DATA/ and overwrite the .profile in autorun.sh with:
cp /share/HDA_DATA/.profile_backup /root/.profile

 


Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169
  • Published in Qnap
  • Read 4313 times

Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478
back to top