Weird environment for usb-storage script?
Thanks Joerg,
I changed my usb-storage script to look like this:
#!/bin/sh
exec >/tmp/foo.$$ 2>&1
set -x
invoke-rc.d ssh start
eject
echo '#!/bin/sh
killall -9 sshd
eject -t' > $REMOVER
chmod 777 $REMOVER
...and it starts and stops the ssh server. Now I just need to read some man pages and figure out what exec and set -x are actually doing :)
Thanks again, Michael
Quoted 10 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Joerg Sommer
Sent: Wednesday, September 17, 2003 11:55 AM
To: [email protected]
Subject: Re: Weird environment for usb-storage script?
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
I am having trouble understanding what 'exec >/tmp/foo.$$ 2>&1' does. I understand that $$ becomes my pid and that stdout and stderr are redirected, but doesn't exec take a command? What am I missing? Also why would my commands not run previously if they generated output on stdout?
- Michael
Quoted 44 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Michael Hale
Sent: Wednesday, September 17, 2003 1:37 PM
To: [email protected]
Subject: [SOLVED] RE: Weird environment for usb-storage script?Thanks Joerg,
I changed my usb-storage script to look like this:
#!/bin/shexec >/tmp/foo.$$ 2>&1
set -x
invoke-rc.d ssh start
ejectecho '#!/bin/sh
killall -9 sshd
eject -t' > $REMOVERchmod 777 $REMOVER
...and it starts and stops the ssh server. Now I just need to read some man pages and figure out what exec and set -x are actually doing :)
Thanks again, Michael
Quoted 10 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Joerg Sommer
Sent: Wednesday, September 17, 2003 11:55 AM
To: [email protected]
Subject: Re: Weird environment for usb-storage script?
Quoted 8 lines
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 10 lines · begin "Michael Hale
Quoted 10 lines
From: [email protected] [mailto:[email protected]] On Behalf Of Michael Hale
Sent: Wednesday, September 17, 2003 1:37 PM
To: [email protected]
Subject: [SOLVED] RE: Weird environment for usb-storage script?I changed my usb-storage script to look like this:
#!/bin/sh
add here: set -e to let the script die, if something returns with an error.
Quoted 9 lines
Quoted 9 lines
exec >/tmp/foo.$$ 2>&1
set -x
invoke-rc.d ssh start
ejectecho '#!/bin/sh
killall -9 sshd
eject -t' > $REMOVER
Quoted 5 lines
Quoted 5 lines
chmod 777 $REMOVER
...and it starts and stops the ssh server. Now I just need to read some man pages and figure out what exec and set -x are actually doing :)
But it shouldn't look so. This is only for debuging. Take a look at /tmp/foo.?? and you see what commands were executed and you see how they are called.
Quoted 3 lines
I am having trouble understanding what 'exec >/tmp/foo.$$ 2>&1' does. I understand that $$ becomes my pid and that stdout and stderr are redirected, but doesn't exec take a command? What am I missing? Also
exec removes normaly the process by another. If exec is called without a command to execute, all that happens to the current process. All output of the current process (produced by set -x) is written to /tmp/foo.??
Quoted 2 lines
why would my commands not run previously if they generated output on stdout?
I don't know why. This is, why you should add debugging output.
Jörg.
end.
Signature · 13 lines
Das Recht, seine Meinung zu wechseln, ist eines der wichtigsten menschlichen Previlegien. (Robert Peel) ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
I added set -e and commented out exec and set -x. My cd still ejects, but ssh fails to start. However when I used exec to send stdout to /dev/null it starts ssh in addition to ejecting the cd. Here is the script I currently have:
#!/bin/sh
exec >/dev/null 2>&1
invoke-rc.d ssh start
eject
echo '#!/bin/sh
killall -9 sshd
eject -t' > $REMOVER
chmod 700 $REMOVER
Quoted 10 lines · begin "Michael Hale
Quoted 10 lines
From: [email protected] [mailto:[email protected]] On Behalf Of Michael Hale
Sent: Wednesday, September 17, 2003 1:37 PM
To: [email protected]
Subject: [SOLVED] RE: Weird environment for usb-storage script?I changed my usb-storage script to look like this:
#!/bin/sh
add here: set -e to let the script die, if something returns with an error.
Quoted 9 lines
Quoted 9 lines
exec >/tmp/foo.$$ 2>&1
set -x
invoke-rc.d ssh start
ejectecho '#!/bin/sh
killall -9 sshd
eject -t' > $REMOVER
Quoted 5 lines
Quoted 5 lines
chmod 777 $REMOVER
...and it starts and stops the ssh server. Now I just need to read some man pages and figure out what exec and set -x are actually doing :)
But it shouldn't look so. This is only for debuging. Take a look at /tmp/foo.?? and you see what commands were executed and you see how they are called.
Quoted 1 line
I am having trouble understanding what 'exec >/tmp/foo.$$ 2>&1' does.
I
Quoted 2 lines
understand that $$ becomes my pid and that stdout and stderr are redirected, but doesn't exec take a command? What am I missing? Also
exec removes normaly the process by another. If exec is called without a command to execute, all that happens to the current process. All output of the current process (produced by set -x) is written to /tmp/foo.??
Quoted 2 lines
why would my commands not run previously if they generated output on stdout?
I don't know why. This is, why you should add debugging output. Jörg.
end.
Signature · 14 lines
Das Recht, seine Meinung zu wechseln, ist eines der wichtigsten
menschlichen Previlegien.
(Robert Peel)
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel