Apr 23 2010

PTY allocation request failed on channel 0

That is the message that greeted me when I tried to log into my VPS (webserver).

I had no way of accessing my box at the console – so I couldn't do much of anything.  All the posts I could find that solved the issue (or presented solutions, anyway) required you to log into the box.  Uhhh…. this is a VIRTUAL SYSTEM.  There is NO console.  How do you log in to fix it, guys?

Continuing my search, I stumbled upon Yak Shaving's blog regarding the same issue.  The magic command? 

 

ssh user@host "/bin/bash -i"
Ah!  Pure magic!!  Back into the system as root.  Just the way it should be.
Please check out his entire entry for the full solution. 

 

 Thanks again Yak.

 

Edit: tldr;
rm -rf /dev/ptmx
mknod /dev/ptmx c 5 2
chmod 666 /dev/ptmx
umount /dev/pts
rm -rf /dev/pts
mkdir /dev/pts
mount /dev/pts

 


Sep 30 2009

Fortune_mod automated Twitter feed

I've been getting a lot of interest in the automatic Twitters I have
set up.  People are curious how I've done it and what it is about.

update:  the link to the feed is http://twitter.com/fortune_mod


Basically, I set up an automatic twitter every half hour, Monday to
Friday between 9am and 5pm.  These tweets are from a linux/unix program written by
many people over the years called Fortune.

Fortune is a simple program which pulls random entries from a database
of quotes, sayings, or anything else of trivial importance.  I believe the
original intent of the program was to provide a fortune cookie for
users who logged into a computer or other similar activity.  Over the
years I have seen it used more as being a generator for tag lines in emails
than anything else.  Each time an email is sent, a new fortune is
used as the tag line at the bottom of emails.  There are many tutorials
available to get this working on many email clients.

I was looking into the programmer's interface that is supplied by the
folks at Twitter
and wanted to set up an automatic twitter.  I am using
fortune mainly because it's readily available.  I decided to write a
simple PHP script that would call fortune, and use the returned text as
the source of a posted tweet.  Here is the code:

// Auto Twitter feed
$message = shell_exec('fortune -s -n 140'); // Get a fortune that is less than 140 characters long
$message = urlencode($message); // encode the message to pass to Twitter
$curl_handle = curl_init(); 
curl_setopt($curl_handle, CURLOPT_URL, 'http://twitter.com/statuses /update.xml');
// Set to use the XML interface
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_POST, 1); // POST instead of GET
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, \"source=$source&status=$message\" ) ; 
curl_setopt($curl_handle, CURLOPT_USERPWD, $USER_NAME . ':' . $PASSWORD);
$buffer = curl_exec($curl_handle); // Send the tweet
curl_close($curl_handle); // Clean up

The next step is to add a cron job which would run the PHP script every half hour.  Cron is a program which runs every minute and looks at a table of entries to determine if there are any applications, scripts or processes that should be run.  Using Cron, you can make programs run automatically at different times, daily, weekly, monthly or every other day even.  For this, I want it to run every half hour only durning business hours.  Here is the cron entry:

*/30 9,10,11,12,13,14,15,16,17 * * * /usr/bin/php ~/twitter.php

 

Hope this helps!