Tiny Core Linux
Tiny Core Extensions => TCE Talk => Topic started by: Daniel on February 07, 2011, 08:59:49 AM
-
Hi,
With my application, I'am waiting for an USB device.
For that, i do "ls /dev/sdb1"
with my application run under ubuntu 10.04, an error goes to stderr.
with tcl, the error goes to stdout.
I've test : 'ls /dev/sdb2 1>t1 2>t2'
the error result is in t1 (t2 for ubuntu).
what have i to do to change that and to have the same as ubuntu in order to do both without change?
thanks
Daniel.
[EDIT]
or an other way of doing the same in both cases? :)
-
To redirect both stdout and stderr to the same output, use "&>" as in:
ls /dev/sdb1 &>t
However, if you are waiting on a usb device there may be better options depending on your use:
1) During bootup, you can use the waitusb bootcode and include the device, label or UUID of a USB device (if it is always the same):
waitusb=7:DEVICE=/dev/sdb1
waitusb=7:UUID=xxxx
waitusb=7:LABEL="label"
2) Use blkid to check for the presence of the device instead of ls:
blkid -lt DEVICE=/dev/sdb1 && echo Success
or
blkid -lt DEVICE=/dev/sdb1 || echo Failed
or
while ! blkid -lt DEVICE=/dev/sdb1; do sleep 0.25; done
-
Thanks!
Now, i'm using blkid to see if an usb device is present.
blkid -o device
with filtering the response.
:)
Daniel.
PS: there is a difference between tcl and ubuntu.
Perhaps because in tcl, stderr is redirected on stdout ? ??? ??? ???
-
PS: there is a difference between tcl and ubuntu.
It may be the shell. Ash and bash use the syntax I gave you. I realize you may not need it now, but you can also redirect like this:
ls -l /dev/sdb1 2>&1 >t
-
Thanks!
What i wanted is to have the same for both ubuntu and tcl.
error -> stderr.
With "blkid", i modify the program for both!
:)
Daniel.