Hack 30. Enabling Bash over the Serial Port

   

Hack 30 Enabling Bash over the Serial Port

figs/moderate.gif figs/hack30.gif

The simplest way to get a prompt on your TiVo is to activate the serial port and connect your TiVo to your PC .

Since the days of yore, one of the most common and simple methods for hooking together two PCs has been to use the serial port. A garden-variety serial cable (I've collected a case of them over the years ) plus a $5 null modem adapter will provide a fine, albeit slow, connection between the two machines. Fire up just about any terminal program (e.g., Windows' HyperTerm), and you can flow text from one machine to the other.

Enabling the Bash shell so that it's available to the serial port the next time your TiVo boots requires command-line access to your TiVo drive. Yes, we know it's a catch-22one solved by mounting the right drive partitions [Hack #29] and turning on the Bash shell. This hack assumes you've already mounted the drive partitions.

You'll be editing the rc.sysinit script that controls what processes and programs are started when TiVo boots up. But first, it serves you well to make backup copies of files you'll be editing, just in case something goes wrong. Type the following commands to get to and make a copy of rc.sysinit as rc.sysinit.orig (as in "original"):

 #  cd /     mnt4     /etc/rc.d  #  cp rc.sysinit rc.sysinit.orig  

If, in [Hack #29], you found that you don't have a partition 4, replace mnt4 in the previous command with mnt7 .

Next, we'll append (the >> bit) a command-line incantation to get the Bash shell running to the end of the rc.sysinit file:

 #  echo '/bin/bash --login < /dev/ttyS3 >& /dev/ttyS3 &' >> rc.sysinit  

You're asking Bash to take its input from ( < /dev/ttyS3 ) and send its output to ( >& /dev/ttyS3 ) the serial port ( /dev/ttyS3 ), instead of from the command line.

At this point, all should be set. You can delete that backup file, or notit's up to you:

 #  rm rc.sysinit.orig  

Most of you should have both a partition 4 and partition 7 [Hack #29]. If you do, it's a good practice to mirror a change made to the active partition on the backup partition. Perform all the previously mentioned command-line steps again, replacing mnt4 with mnt7 , like so:

 #  cd /   mnt7   /etc/rc.d  #  cp rc.sysinit rc.sysinit.orig  #  echo '/bin/bash --login < /dev/ttyS3 >& /dev/ttyS3 &' >> rc.sysinit  #  rm rc.sysinit.orig  

Again, removing the backup rc.sysinit.orig file is optional.

Instead of the commands recommended in this hack, many guides found on the Internet recommend that you run this:

 echo '/bin/bash < /dev/ttyS3 >& /dev/ttyS3 &' >> rc.sysinit 

While it is completely up to you, I recommend the one with --login on the command line, as that will evaluate /.profile when the TiVo starts up.

Go To

All that remains is a little cleanup and a shut down [Hack #32]. But, before you go, it behooves you to copy over a few useful Unix utilities [Hack #31].


   
Top


Tivo Hacks. 100 Industrial-strength Tips Tools 2003
Tivo Hacks. 100 Industrial-strength Tips Tools 2003
ISBN: 1597490318
EAN: N/A
Year: 2004
Pages: 164

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net