ps output redirection problem

hinko.kocevar at cetrtapot.si hinko.kocevar at cetrtapot.si
Wed Mar 28 10:02:10 UTC 2007


Ignacio García Pérez wrote:
> Hi,
> 
> I just noticed that
> 
> ps > out.txt
> 
> ps 2>&1 > out.txt
> 
> Produce an empty out.txt file. If no output redirection is used, the 
> output of the ps command is as expected.
> 
> Any idea of what's wrong?

Both commands work on my embedded system:
# ps  > out1.txt
# cat out1.txt
   PID  Uid     VmSize Stat Command
     1 root        264 S   init
     2 root            SWN [ksoftirqd/0]
     3 root            SW< [events/0]
     4 root            SW< [khelper]
     5 root            SW< [kthread]
     6 root            SW< [kblockd/0]
     7 root            SW< [khubd]
     8 root            SW  [pdflush]
     9 root            SW  [pdflush]
    11 root            SW< [aio/0]
    10 root            SW  [kswapd0]
    12 root            SW  [mtdblockd]
    13 root            SW< [rpciod/0]
   306 root        216 S   /sbin/syslogd
   338 root        176 S   /sbin/klogd -c 7
   370 root         80 S   /sbin/telnetd
   409 root        432 S   /sbin/dropbear
   441 root        144 S   /sbin/httpd -c /etc/bbhttpd.conf -h /www/pages
   473 root        200 S   /sbin/crond -c /etc/crontab
   505 root        280 S   /bin/linkstat -b -r 10.0.0.1
   705 root        232 S   sh /program/runppp.sh
   717 root        280 S   /bin/sh
   722 root        576 S   /sbin/pppd /dev/ircomm0 nodetach init 
/etc/ppp/init.s
   742 root        224 S   sh -c /bin/ppp_wince_chat
   743 root        208 S   /bin/ppp_wince_chat
  4084 root        200 R   ps
# ps 2>&1 > out2.txt
# cat out2.txt
   PID  Uid     VmSize Stat Command
     1 root        264 S   init
     2 root            SWN [ksoftirqd/0]
     3 root            SW< [events/0]
     4 root            SW< [khelper]
     5 root            SW< [kthread]
     6 root            SW< [kblockd/0]
     7 root            SW< [khubd]
     8 root            SW  [pdflush]
     9 root            SW  [pdflush]
    11 root            SW< [aio/0]
    10 root            SW  [kswapd0]
    12 root            SW  [mtdblockd]
    13 root            SW< [rpciod/0]
   306 root        216 S   /sbin/syslogd
   338 root        176 S   /sbin/klogd -c 7
   370 root         80 S   /sbin/telnetd
   409 root        432 S   /sbin/dropbear
   441 root        144 S   /sbin/httpd -c /etc/bbhttpd.conf -h /www/pages
   473 root        200 S   /sbin/crond -c /etc/crontab
   505 root        280 S   /bin/linkstat -b -r 10.0.0.1
   705 root        232 S   sh /program/runppp.sh
   717 root        280 S   /bin/sh
   722 root        576 S   /sbin/pppd /dev/ircomm0 nodetach init 
/etc/ppp/init.s
   742 root        224 S   sh -c /bin/ppp_wince_chat
   743 root        208 S   /bin/ppp_wince_chat
  4086 root        200 R   ps
#

regards,
hinko

-- 
ČETRTA POT, d.o.o., Kranj
Planina 3
4000 Kranj
Slovenia, Europe
Tel. +386 (0) 4 280 66 03
E-mail: hinko.kocevar at cetrtapot.si
Http: www.cetrtapot.si




More information about the busybox mailing list