PDA

View Full Version : Problems exporting environment variables.



ice5
09-28-2003, 10:32 PM
OK, so I have an HDVR2

For the longest time I couldn't get fixsub.tcl or 51killer.tcl to work.

So it turns out that the environment variables were not being properly exported.

My Hackinit:



#!/bin/bash
date>>/var/hack/hackinit.log
PATH=/var/hack/bin:/sbin:/bin:/tivobin:/tvbin:.
/bin/bash</dev/ttyS2&>/dev/ttyS2&
TIVO_ROOT=
MFS_DEVICE=/dev/hda10
IGNOREEOF=1000
export PATH TIVO_ROOT MFS_DEVICE IGNOREEOF

Ethernet

insmod /diag/usbcore.o
insmod /diag/usb-ohci.o
insmod /diag/pegasus.o
sleep 15

ifconfig eth0 192.168.2.200 broadcast 192.168.2.255 netmask 255.255.255.0
route add default gw 192.168.2.1 netmask 0.0.0.0 metric 1

#Telnet
tnlited 23 /bin/bash -login &

#FTP
tivoftpd

#TiVoWEB
/var/hack/tivoweb-tcl/tivoweb console

#KMEM
kmem 800b23b4 00001021

#FIXSUB
sleep 60
/var/hack/rpl-fixsub.tcl



But this is the output of an "export" command:



bash-2.02# export
declare -x HOME="/"
declare -x HOSTNAME="(none)"
declare -x HOSTTYPE="i686"
declare -x MACHTYPE="i686-pc-linux-gnu"
declare -x OSTYPE="linux-gnu"
declare -x PATH="/var/hack/bin:/sbin:/bin:/tivobin:/tvbin:."
declare -x PWD="/var/hack"
declare -x SHELL="/bin/sh"
declare -x SHLVL="2"
declare -x TERM="linux"
declare -x root="/dev/hda7"


So none of my scripts would work until I did this:



TIVO_ROOT=; export TIVO_ROOT
MFS_DEVICE=/dev/hda10; export MFS_DEVICE
IGNOREEOF=1000; export IGNOREEOF


This naturally means I cannot run scripts from within my hackinit...

My questions:

1) Why are my environment variables not being exported properly? The PATH variable is properly exported.

2) How can I tell what is, and what isn't properly executing in my hackinit.

i.e. the FTP server is running, telnet and tivoweb are not. Is KMEM running?

3) Do I need to invoke the KMEM in the hackinit, or is it a one time thing?

Sleeper
09-29-2003, 11:48 PM
Here is an explanation of how enviroment variables work. I found this in another forum:

The export command makes the value of a variable available to the current process and to subprocesses, but not to parent processes!

When you create a shell script and execute it, a new shell process is started to execute the contents of that script. Any exported variable values are available to the new shell, or to any subprocesses the new shell creates. When the script ends, none of the exported variable values are available to the parent process (your login shell).

When you log in, the first thing that the login shell does is runs your login script (e.g. ~/.bash_profile), which is why any exported variable values in that script are available to you from that point on.

Adding the . before you execute sample.sh (for example: . ./sample.sh) will work. The . is a shell builtin command that causes the script to be read and executed in the current shell process rather than starting a new shell process to do that. That is why exported variable values are available to your login shell. You can do the same thing with "source ./sample.sh" since source and . mean the same thing.

So I would venture to say that it depends on how the romfs calls bash and how bash calls hackinit script.

I believe that you are having an isolated problem.

Sleeper
09-29-2003, 11:57 PM
Originally posted by ice5

3) Do I need to invoke the KMEM in the hackinit, or is it a one time thing?

Invoke from hackinit everytime machine boots.

If I remember correctly, you were having some other issues getting things working.

http://www.dealdatabase.com/forum/showthread.php?s=&threadid=27829

You never said if or how you got BASH working. And the fact that you stated that you could not generate the romfs raises and eyebrow.

I would look at your bootpage
bootpage -p /dev/hdc

Check the output with Cobellis howto. Many imistakes are make here.

ice5
09-30-2003, 04:43 PM
Generating the romfs was never a problem.

The problem was that I followed the guide exactly, and as soon as I booted the TiVo it would wipe the /var/hack directory. This is on a virgin drive image. Also, I double checked that the logs were empty.

What I ended up doing, was constructing a serial cable, and installing the pre-hacked mfs file floating around. Everything then worked, except I had to manually export the environment variables. This was all while using serial bash.

When I tried using Telnet bash, the environment variables had been exported.

So once I figured that out, I ran fixsub and 51killer in telnet.

I took the box downstairs, and my HU card hack had not worked, so I couldn't use it.

(I know we can't discuss DTV hacking, I'm just giving my story)

So I brought the box back upstairs to tinker with some more.

I should mention that while running the scripts, etc. the box went through many reboots without issue. It booted fine when I brought it downstairs too.

However, once I plugged it in upstairs, I had a reboot loop happening. I'm not sure if the loop was because of the messed up HU hack or what, but I will be re-imaging again tonight.

metrotech
09-30-2003, 05:49 PM
ice5

How do your tcl scripts start just post a few lines.

MT

ice5
09-30-2003, 08:02 PM
Originally posted by metrotech
ice5

How do your tcl scripts start just post a few lines.

MT

Well, when I tried to run them from serial bash without manually exporting environment variables, I would get an error, and the TiVo would reboot.

However, after manually exporting the variables, or running the script from telnet, everything went fine.

Sleeper
09-30-2003, 10:13 PM
Originally posted by ice5
The problem was that I followed the guide exactly, and as soon as I booted the TiVo it would wipe the /var/hack directory.

Look, the first time I followed the guide I thought that I followed it exactly as well. Turns out that I made a mistake. The guide is correct all except for the last period in the PATH statement.



What I ended up doing, was constructing a serial cable, and installing the pre-hacked mfs file floating around. Everything then worked, except I had to manually export the environment variables. This was all while using serial bash.

I don't know about the mfs file floating around. It sounds like it is not working correctly and your hackinit is not being "sourced". I would try cobelli's howto again. More likely than not you are doing it wrong.

metrotech
10-01-2003, 05:04 PM
ice5

I had problems with this also if you would post the first say 8 lines of how your scripts start I might be able to see if it is the same way my scripts used to start. I didn't have a reboot problem, the scripts would just error out.

MT