{"id":366,"date":"2013-05-16T01:49:51","date_gmt":"2013-05-16T01:49:51","guid":{"rendered":"https:\/\/shan.info\/new\/screen-var-run-utmp-no-such-file-or-directory-cannot-find-termcap-entry-for\/"},"modified":"2013-05-16T01:49:51","modified_gmt":"2013-05-16T01:49:51","slug":"screen-var-run-utmp-no-such-file-or-directory-cannot-find-termcap-entry-for","status":"publish","type":"post","link":"https:\/\/shan.info\/new\/screen-var-run-utmp-no-such-file-or-directory-cannot-find-termcap-entry-for\/","title":{"rendered":"# screen \/var\/run\/utmp: No such file or directory Cannot find termcap entry for &#8216;&#8230;&#8217;"},"content":{"rendered":"<h2 style=\"color: #000000; background-image: none; margin: 0px 0px 0.6em; padding-top: 0.5em; padding-bottom: 0.17em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: #aaaaaa; font-size: 19px; font-family: sans-serif; line-height: 19.046875px;\"><span id=\"QNAP_screen_command_broken-ness\" class=\"mw-headline\">QNAP screen command broken-ness<\/span><\/h2>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">On the QNAP per default the screen command is not configured properly. When running screen the following errors are output.<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\"># screen\r\n\/var\/run\/utmp: No such file or directory\r\nCannot find termcap entry for '...'<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">(Where &#8230; is a placeholder for xterm-color, xterm-256color or any file which is not available on the QNAP.)<\/p>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">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.<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\"># touch \/var\/run\/utmp<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">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:<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\">#\u00a0export | grep xterm<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">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:<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\"># ls \/usr\/share\/terminfo\/x\/<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">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.<\/p>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">Knowing this gives you a few options for solving this:<\/p>\n<ul style=\"line-height: 19.046875px; list-style-type: square; margin: 0.3em 0px 0px 1.5em; padding: 0px; list-style-image: url('http:\/\/wiki.qnap.com\/w\/skins\/monobook\/bullet.gif'); color: #000000; font-family: sans-serif; font-size: 13px;\">\n<li style=\"margin-bottom: 0.1em;\">Changing the terminal preferences to use xterm.<\/li>\n<li style=\"margin-bottom: 0.1em;\">Make sure the TERM environment variable on your QNAP is pointing to xterm-xfree86.<\/li>\n<li style=\"margin-bottom: 0.1em;\">Create one or more symbolic links from the requested xterm file to xterm-xfree86.<\/li>\n<\/ul>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">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 &#8230;) to its successor xterm-xfree86.<\/p>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">But&#8230;<\/p>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">Once you have modified your QNAP and restarted it, you may find all settings are lost. So how to make this persistent?<\/p>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">See\u00a0<a href=\"http:\/\/wiki.qnap.com\/wiki\/How_to_install_the_BackupPC_application#Automatic_startup_of_BackupPC_when_system_boots\" title=\"How to install the BackupPC application\" style=\"color: #5a3696; background-image: none;\">Automatic startup &#8230; when system boots<\/a>\u00a0for tips on keeping settings and software persistent.<\/p>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">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):<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\">mount -t ext2 \/dev\/sdx6 \/tmp\/config\r\nvi \/tmp\/config\/autorun.sh<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">Add the following lines:<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\">#!\/bin\/sh\r\n# start a single script\r\n\/share\/MD0_DATA\/custom\/autorunmaster.sh\r\n# finish<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">Ensure that \/tmp\/config\/autorun.sh is executable:<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\">chmod +x \/tmp\/config\/autorun.sh<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">Then unmount with:<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\">umount \/tmp\/config<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">Now create a directory:<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\">mkdir \/share\/MD0_DATA\/custom\/<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">Edit the file autorunmaster.sh<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\">vi \/share\/MD0_DATA\/custom\/autorunmaster.sh<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">Add or enter the following:<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\">#!\/bin\/sh\r\n# This is the autorunmaster file which is executed from\r\n# mounted device \/dev\/sdx6\/ with file autorun.sh\r\n# Enter below your scripts and comments\r\n#\r\n# Fix broken screen command which has missing file\r\n# \/var\/run\/utmp and may have missing environment\r\n# variables for TERM, as such pointing to a non-existing\r\n# xterm file like xterm-color.\r\ntouch \/var\/run\/utmp\r\nln -s \/usr\/share\/terminfo\/x\/xterm-xfree86 \/usr\/share\/terminfo\/x\/xterm-256color\r\nln -s \/usr\/share\/terminfo\/x\/xterm-xfree86 \/usr\/share\/terminfo\/x\/xterm-color<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">And make sure that autorunmaster.sh is executable:<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\">chmod +x \/share\/MD0_DATA\/custom\/autorunmaster.sh<\/pre>\n<h4 style=\"color: #000000; background-image: none; margin: 0px 0px 1.3em; padding: 25px 0px 0px; border-bottom-style: none; font-size: 15px; font-family: sans-serif; line-height: 19.046875px;\"><span id=\"Troubleshooting\" class=\"mw-headline\">Troubleshooting<\/span><\/h4>\n<ul style=\"line-height: 19.046875px; list-style-type: square; margin: 0.3em 0px 0px 1.5em; padding: 0px; list-style-image: url('http:\/\/wiki.qnap.com\/w\/skins\/monobook\/bullet.gif'); color: #000000; font-family: sans-serif; font-size: 13px;\">\n<li style=\"margin-bottom: 0.1em;\">Message &#8216;Aborted because of window size change&#8217; appears. Disable remote-controlled terminal resizing, which is in\u00a0<a class=\"external text\" href=\"http:\/\/www.chiark.greenend.org.uk\/~sgtatham\/putty\/\" rel=\"nofollow\" style=\"color: #3366bb; background-image: url('http:\/\/wiki.qnap.com\/w\/skins\/monobook\/external.png'); padding-right: 13px; background-position: 100% 50%; background-repeat: no-repeat no-repeat;\">Putty<\/a>\u00a0in Terminal -&gt; Features<\/li>\n<li style=\"margin-bottom: 0.1em;\">If \/share\/MD0_DATA does not exist you may need to use\u00a0 \/share\/HDA_DATA instead depending on your disk configuration<\/li>\n<\/ul>\n<h3 style=\"color: #000000; background-image: none; margin: 0px 0px 1.3em; padding: 25px 0px 0px; border-bottom-style: none; font-size: 17px; font-family: sans-serif; line-height: 19.046875px;\"><span id=\"Alternative_solution\" class=\"mw-headline\">Alternative solution<\/span><\/h3>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">If for some reason the above mentioned does not work, the following might. Run the screen command with an exported variable:<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\"># TERMINFO='\/usr\/share\/terminfo\/' screen<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">or<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\"># export TERMINFO='\/usr\/share\/terminfo\/'\r\n# screen<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">To make this setting permanent, you can add this to your .profile, before the &#8216;reset&#8217; line<\/p>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\">export PS1='[w] # '\r\nexport TERMINFO='\/usr\/share\/terminfo\/'\r\nreset<\/pre>\n<p style=\"margin: 0.4em 0px 0.5em; line-height: 19.046875px; color: #000000; font-family: sans-serif; font-size: 13px;\">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.<\/p>\n<h4 style=\"color: #000000; background-image: none; margin: 0px 0px 1.3em; padding: 25px 0px 0px; border-bottom-style: none; font-size: 15px; font-family: sans-serif; line-height: 19.046875px;\"><span id=\"Troubleshooting_2\" class=\"mw-headline\">Troubleshooting<\/span><\/h4>\n<ul style=\"line-height: 19.046875px; list-style-type: square; margin: 0.3em 0px 0px 1.5em; padding: 0px; list-style-image: url('http:\/\/wiki.qnap.com\/w\/skins\/monobook\/bullet.gif'); color: #000000; font-family: sans-serif; font-size: 13px;\">\n<li style=\"margin-bottom: 0.1em;\">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:<\/li>\n<\/ul>\n<pre style=\"padding: 1em 1em 25px; border: 1px dashed #2f6fab; background-color: #eeeeee; line-height: 1.1em; overflow-x: auto; width: 1231.0625px;\">cp \/share\/HDA_DATA\/.profile_backup \/root\/.profile\r\n<\/pre>\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8216;&#8230;&#8217; (Where &#8230; is a placeholder for xterm-color, xterm-256color or any file which is not available on the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[50],"tags":[],"class_list":["post-366","post","type-post","status-publish","format-standard","hentry","category-qnap"],"_links":{"self":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts\/366","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/comments?post=366"}],"version-history":[{"count":0,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/posts\/366\/revisions"}],"wp:attachment":[{"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/media?parent=366"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/categories?post=366"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shan.info\/new\/wp-json\/wp\/v2\/tags?post=366"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}