2008-09-09 13:40:54     hotplug environment question

Document created by Aaronwu Employee on Aug 7, 2013
Version 1Show Document
  • View in full screen mode

2008-09-09 13:40:54     hotplug environment question

Ron Weiland (UNITED STATES)

Message: 61845   

 

Hi all,

 

I'm trying to use the hotplug facility for USB automount, but have a small issue.   When I run a command from the hotplug script the output of the command does not go to the environment as expected.  Take this simple script for example:

 

#!/bin/sh

 

outfile=/home/logdev.$$

 

if [ "$ACTION" = add ]; then

        if [ "$SUBSYSTEM" = block ]; then

                ST=`echo hello`

                echo "ST= $ST"  > $outfile

        fi

fi

 

 

If executed from the shell, this works fine and outputs ST= hello.  If executed from the hotplug script, $ST is empty, as is any variable I try to assign from the output of any command.

 

If I write the environment out to a file from the hotplug script after executing the echo command, ST exists but is empty.   Is this normal behavior, or related to the Blackfin?  How can I get the results of a command back to the script?

 

Also, it seems the hotplug events are cached (13 of them in my case), and executed simultaneously.  Is that also normal behavior?

 

Cheers, and thanks!

 

Ron Weiland

 

 

QuoteReplyEditDelete

 

 

2008-09-09 15:57:04     Re: hotplug environment question

Mike Frysinger (UNITED STATES)

Message: 61848   

 

if you search the forums, you'll find you need to add some exec statements to recreate the standard 0/1/2 file descriptors, otherwise capturing output of subshells does not work

QuoteReplyEditDelete

 

 

2008-09-09 18:07:02     Re: hotplug environment question

Ron Weiland (UNITED STATES)

Message: 61850   

 

Thanks a lot, Mike.  Found it and got it working.  I Should have done a better search.

 

Ron Weiland

Attachments

    Outcomes