Problem running hush shell script from within a script
Adam Rosenberg
adam at alcorn.com
Fri Aug 6 18:56:25 UTC 2010
Denys,
I have made two scripts based on my tests so that you can see exactly
what I am doing. I can now reproduce this problem using the following
steps:
boot the system
1. mainscript.sh start
2. module is loaded but the character device does not work
it works 100% of the time this way:
boot the system
1. subscript.sh start
2. subscript.sh write "test"
3. the "test" message appears on my LCD
if you then remove the module and try mainscript it works 50% of the time:
boot the system
1. subscript.sh start
2. subscript.sh write "test"
3. the "test" message appears on my LCD
4. subscript.sh stop
5. mainscript.sh start
6. sometimes the message "Test Message" appears and sometimes it does not
Here are the scripts:
mainscript.sh follows:
<----------------- cut here ----------------->
#!/bin/hush
SUBSCRIPT="/bin/subscript.sh"
if [ -z "$1" ]
then
echo "Usage $0 [start|stop]"
exit
fi
if [ "$1" == "start" ]
then
echo "Main: Starting subscript"
$SUBSCRIPT start
sleep 2
echo "Main: Writing to device"
$SUBSCRIPT write "Test Message"
exit
fi
if [ "$1" = "stop" ]
then
$SUBSCRIPT stop
exit
fi
<----------------- cut here ----------------->
subscript.sh follows:
<----------------- cut here ----------------->
#!/bin/hush
DEVMODULE="traxxLCDDrv.ko"
DEVDEVICE="/dev/ami_traxx_lcd"
if [ -z "$1" ]
then
echo "Usage $0 [start|stop|write]"
exit
fi
if [ "$1" == "start" ]
then
echo "Sub: Loading module"
modprobe $DEVMODULE
exit
fi
if [ "$1" = "stop" ]
then
echo "Sub: Removing module"
rmmod $DEVMODULE
exit
fi
if [ "$1" = "write" ]
then
echo "Sub: echo -n \"000 000 $2\" > $DEVDEVICE"
echo -n "000 000 $2" > $DEVDEVICE
exit
fi
<----------------- cut here ----------------->
I can send you the LCD driver code if you need to see it. What do you
think might be happening?
Thanks,
Adam
More information about the busybox
mailing list