You are not logged in.
Pages: 1
Hi,
somehow I found following commands give me nothing:
ps | grep bin
ps and grep do work and give me correct results by following:
ps > ps.out
grep bin ps.out
I wondering how this can happen?!
And how can I figure out what's going wrong?!
Thanks.
BR,
bsdson
edit: this problem is not related to "pipe" but the option I used in the "grep" command.
Last edited by bsdson.tw (2012-03-30 11:04:36)
Offline
┌─[Archer ~]
└─╼ ps
PID TTY TIME CMD
13500 pts/2 00:00:00 bash
13816 pts/2 00:00:00 ps
Offline
Extract from ps manpage:
By default, ps selects all processes with the same effective user ID
(euid=EUID) as the current user and associated with the same terminal
as the invoker. It displays the process ID (pid=PID), the terminal
associated with the process (tname=TTY), the cumulated CPU time in
[dd-]hh:mm:ss format (time=TIME), and the executable name (ucmd=CMD).
Output is unsorted by default.
What output containing "bin" are you seeing exactlty by just running "ps"?
Burninate!
Offline
I have aliased my "ps" as:
alias ps='/bin/ps -U henry -o pid,bsdstart,state,rss,args -H'
and the output is like:
[henry@henry_u59 ~]$ ps
PID START S RSS COMMAND
821 15:19 S 9340 gnome-session
848 15:19 S 17408 /usr/lib/gnome-settings-daemon/gnome-settings-daemon
883 15:19 S 99180 /usr/bin/gnome-shell
1018 15:20 S 21628 gnome-terminal
1025 15:20 S 720 gnome-pty-helper
1026 15:20 S 3808 bash
26206 10:49 R 948 /bin/ps -U henry -o pid,bsdstart,state,rss,args -H
1101 15:20 S 308832 firefox
1177 15:20 S 111988 /usr/lib/firefox/plugin-container /usr/lib/mozilla/p
1144 15:20 S 85172 skype
2272 16:17 S 1676 /bin/bash /usr/bin/eclipse
2273 16:17 S 964 /usr/share/eclipse/eclipse
2288 16:17 S 697284 /opt/java/bin/java -Xms40m -Xmx384m -XX:MaxPermSiz
5555 18:09 S 50420 empathy
896 15:19 S 7680 ibus-daemon --xim
902 15:19 S 3588 /usr/lib/ibus/ibus-gconf
904 15:19 S 32284 python2 /usr/share/ibus/ui/gtk/main.py
935 15:19 S 46200 /usr/lib/ibus/ibus-engine-chewing --ibus
900 15:19 S 10112 nm-applet
905 15:19 S 13932 /usr/lib/gnome-disk-utility/gdu-notification-daemon
907 15:19 S 13320 gnome-screensaver
2352 16:17 S 1268 adb fork-server server
1511 15:43 S 2748 /usr/lib/gvfs/gvfsd-metadata
1502 15:43 S 3560 /usr/lib/gvfs/gvfsd-trash --spawner :1.6 /org/gtk/gvfs/exec
1116 15:20 S 2972 /usr/lib/at-spi2-core/at-spi-bus-launcher
1066 15:20 S 14176 /usr/lib/telepathy/telepathy-gabble
998 15:20 S 5768 /usr/lib/telepathy/telepathy-logger
996 15:20 S 5136 /usr/lib/libsocialweb/libsocialweb-core
951 15:19 S 14252 /usr/lib/gnome-online-accounts/goa-daemon
947 15:19 S 6060 /usr/lib/telepathy/mission-control-5
943 15:19 S 4188 /usr/lib/gvfs/gvfs-gdu-volume-monitor
941 15:19 S 6264 /usr/lib/gnome-shell/gnome-shell-calendar-server
913 15:19 S 7472 /usr/lib/ibus/ibus-x11 --kill-daemon
892 15:19 S 2920 /usr/lib/dconf/dconf-service
877 15:19 S 4888 /usr/lib/gnome-settings-daemon/gsd-printer
872 15:19 S 7208 /usr/bin/pulseaudio --start --log-target=syslog
874 15:19 S 2636 /usr/lib/pulse/gconf-helper
865 15:19 S 2540 /usr/lib/gvfs//gvfs-fuse-daemon /home/henry/.gvfs
858 15:19 S 2396 /usr/lib/gvfs/gvfsd
846 15:19 S 3036 /usr/lib/GConf/gconfd-2
839 15:19 S 5600 /usr/bin/dbus-daemon --fork --print-pid 5 --print-address 7
838 15:19 S 600 /usr/bin/dbus-launch --sh-syntax --exit-with-session
804 15:19 S 13100 /usr/bin/gnome-keyring-daemon --daemonize --login
this command
ps | grep <some text>
always works, until recently...
another command with "pipe" does not work neither:
alias | grep ps
BR,
Henry
Offline
Using ps is a bit different to ps -U Henry -o pid,bsdstart,state,rss,args -H, but nevertheless it should work. I just ran first the full command (with my username) and piped it to grep and it gave the correct output, then I aliased it to ps, and ran that, and it worked, so I don't know what's going on. Also, alias | grep ps worked as well.
D:
Offline
Would it be possible to post your entire .bashrc?
Burninate!
Offline
Sure.
[greg@spacebar ~]$ cat .bashrc
#
# ~/.bashrc
#
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls -F'
PS1='[\u@\h \W]\$ '
alias pacman='sudo pacman'
Try making a backup of your .bashrc file, then stripping back to basics, logging out and logging back in and see if it still happens.
EDIT: Haha woops, thought GCool was OP asking me. Anyway, my suggestion still stands.
Last edited by MisterAnderson (2012-03-24 01:57:58)
D:
Offline
Here is mine:
[henry@henry_u59 ~]$ cat .bashrc
#
# ~/.bashrc
## If not running interactively, don't do anything
[[ $- != *i* ]] && returnshopt -s checkwinsize
complete -cf sudo
complete -c manexport EDITOR=vim
export HISTCONTROL=erasedups
export PAGER=less
export GREP_OPTIONS="-I --color=auto --devices=skip --directories=recurse -s"
PS1='[\u@\h \W]\$ '
# ------------------------------------------------------------
# ls
alias ls="ls --color=auto -q"
alias la="ls --color=auto -Aq"
alias ll="ls --color=auto -lhGq"# file
alias diff="diff -cr"# file io
alias cp="cp -ir"
alias mv="mv -i"
alias rm="echo use \"trash\" instead or use \"/bin/rm -i\""alias vi=vim
# network
alias route="route -n"# process
alias ps="/bin/ps -U $(whoami) -o pid,bsdstart,state,rss,args -H"
alias psA="/bin/ps -A -o pid,bsdstart,state,rss,euser,args -H"# disk
alias free="free -m"
alias df="df -h"
alias du="du -hs"
I have just tried this and still doesn't work:
/bin/ps | /bin/grep pts
Offline
A quick rant against the first 2 replies: Read his OP again, he specifically stated that when '>' piping to a file and grepping the file, the output was correct, meaning it's diffrent from the | pipe, which it shouldn't be. There's no point in telling him that ps by default *probably* doesn't do what he expects.
Yesterday I had a problem with zsh, where: for i in `seq 1 100`; do X; done
would print the seq command to stdout rather than using it in the for loop.
I recompiled zsh from source and it worked - so there could be something broken int the binary package, or I just screwed something up elsewhere.
So, given my recent experiences, I'd ask you to try recompiling bash from source and see if it changes anything, even if that's not the way it's supposed to be done.
But if it helps, then the shell packages (or more likely what they commonly depend on) need checking...
Last edited by Blµb (2012-03-26 08:33:15)
You know you're paranoid when you start thinking random letters while typing a password.
A good post about vim
Python has no multithreading.
Offline
A quick rant against the first 2 replies: Read his OP again...
Perhaps, rather than ranting, you should read the thread again. The OP's problem -that he neglected to mention until his second post- is that he aliased `ps`
Little details like that matter.
Offline
Thanks, jasonwryan and Blµb!
I have made a quick exam by re-install bash
both "4.2.024-2" and "4.2.020-1",
but neither work.
I will try to compile it on my own and report the result later.
Thank you very much!
Offline
BTW,
may I ask...
is the function "pipe" provided by "bash" itself or by another program or another library (like... readline?)
or by some underlying IPC mechanism? memory sharing? socket?
Is there any other way I can diagnose the system?
BR,
Henry
Offline
failed to make bash... o.O
configure: creating ./config.status
config.status: creating Makefile
config.status: creating builtins/Makefile
config.status: creating lib/readline/Makefile
config.status: creating lib/glob/Makefile
config.status: creating lib/intl/Makefile
config.status: creating lib/malloc/Makefile
config.status: creating lib/sh/Makefile
config.status: creating lib/termcap/Makefile
config.status: creating lib/tilde/Makefile
config.status: creating doc/Makefile
config.status: creating support/Makefile
config.status: creating po/Makefile.in
config.status: creating examples/loadables/Makefile
config.status: creating examples/loadables/perl/Makefile
config.status: creating config.h
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
config.status: executing default commands
bison -y -d ./parse.y
conflicts: 1 shift/reduce
touch parser-built
rm -f mksyntax
gcc -DPROGRAM='"bash"' -DCONF_HOSTTYPE='"x86_64"' -DCONF_OSTYPE='"linux-gnu"' -DCONF_MACHTYPE='"x86_64-unknown-linux-gnu"' -DCONF_VENDOR='"unknown"' -DLOCALEDIR='"/usr/share/locale"' -DPACKAGE='"bash"' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -g -o mksyntax ./mksyntax.c
In file included from ./mksyntax.c:25:0:
/usr/include/stdio.h:103:19: error: two or more data types in declaration specifiers
In file included from /usr/include/stdlib.h:320:0,
from ./bashansi.h:36,
from ./mksyntax.c:26:
/usr/include/sys/types.h:36:17: error: two or more data types in declaration specifiers
/usr/include/sys/types.h:36:17: error: two or more data types in declaration specifiers
/usr/include/sys/types.h:37:18: error: two or more data types in declaration specifiers
/usr/include/sys/types.h:37:18: error: two or more data types in declaration specifiers
/usr/include/sys/types.h:66:17: error: two or more data types in declaration specifiers
/usr/include/sys/types.h:71:18: error: two or more data types in declaration specifiers
/usr/include/sys/types.h:81:17: error: two or more data types in declaration specifiers
/usr/include/sys/types.h:99:17: error: two or more data types in declaration specifiers
In file included from /usr/include/sys/types.h:133:0,
from /usr/include/stdlib.h:320,
from ./bashansi.h:36,
from ./mksyntax.c:26:
/usr/include/time.h:60:19: error: two or more data types in declaration specifiers
/usr/include/time.h:76:18: error: two or more data types in declaration specifiers
In file included from /usr/include/sys/types.h:220:0,
from /usr/include/stdlib.h:320,
from ./bashansi.h:36,
from ./mksyntax.c:26:
/usr/include/sys/select.h:38:20: error: two or more data types in declaration specifiers
In file included from ./mksyntax.c:31:0:
/usr/include/unistd.h:275:21: error: two or more data types in declaration specifiers
make: *** [mksyntax] Error 1
==> ERROR: A failure occurred in build().
Aborting...
[henry@henry_u59 bash]$
...
Offline
(...)
is the function "pipe" provided by "bash" itself or by another program or another library (like... readline?)
(...)
By bash (as it is in any other shell I know of - often implemented by creating an unnamed pipe(2) and using dup2(2) to replace the first program's stdout and the second program's stdin.)
bsdson.tw:
Are you using makepkg in the package from core, or the sources directly?
Though the error doesn't look like it depends on that.
Do you have gcc or gcc-multilib. Which version / how up-to-date is your system in general?
Are your base-devel group and the build-time dependencies listed in bash's PKGBUILD up to date?
If so, check the header files it complains about (/usr/include/stdio.h), maybe there's some corruption in there?
(That could be fixable by reinstalling glibc)
EDIT:
Works for me, I have the following versions:
wry:~/ $ pacman -Qqi gcc gcc-libs glibc readline pacman make ncurses binutils-multilib |grep Version [15:54:33]
Version : 4.7.0-1
Version : 4.7.0-1
Version : 2.15-7
Version : 6.2.002-1
Version : 4.0.2-1
Version : 3.82-4
Version : 5.9-3
Version : 2.22-4.1
Nevermind gcc 4.7, it should definitely work with the one in the current repo (4.6.3) or any other gcc... (haha... maybe not... I blame GNU if it doesn't ), also, it shouldn't make any difference that I have non-multilib gcc but binutils-multilib.
Last edited by Blµb (2012-03-27 13:55:56)
You know you're paranoid when you start thinking random letters while typing a password.
A good post about vim
Python has no multithreading.
Offline
Hi,
my system is quite up-to-date.
[henry@henry_u59 ~]$ pacman -Q gcc gcc-libs glibc readline pacman make ncurses lib32-gcc-libs readline binutils-multilib gcc 4.6.3-1
gcc-libs 4.6.3-1
glibc 2.15-7
readline 6.2.002-1
pacman 4.0.2-1
make 3.82-4
ncurses 5.9-3
lib32-gcc-libs 4.6.3-1
readline 6.2.002-1
error: package 'binutils-multilib' was not found
[henry@henry_u59 ~]$
and... according to your explaination of how "pipe" works,
may it related to the file system: "pts" "shm"?
I recently removed 2 entries in fstab to mount "pts" and "shm",
because I have heard those 2 has been handled in rc.sysinit...
ps. I have re-installed glibc and readline, but still can successfully make bash package.
Offline
I just found it probably related to some kind of permission problem...
because "pipe" works correctly in "root@console",
but not "me@x window terminal" nor "root@x window terminal"...
BR,
Henry
Offline
You mean you can pipe as root in a console, but not as user/root in X?
Does it only affect ps | grep, or also other commands... 'echo aaa | cat' for example?
What shell are you using? Do root and your user use the same shell?
Do you have anything out of the ordinary installed? Any special permissions set?
Are you using selinux/apparmor/tomoyo?
You know you're paranoid when you start thinking random letters while typing a password.
A good post about vim
Python has no multithreading.
Offline
You mean you can pipe as root in a console, but not as user/root in X?
Does it only affect ps | grep, or also other commands... 'echo aaa | cat' for example?
What shell are you using? Do root and your user use the same shell?
Do you have anything out of the ordinary installed? Any special permissions set?
Are you using selinux/apparmor/tomoyo?
<as root in console>
I can successfully execute following commands:
ps -Af | grep usr
echo abc | grep a
echo abc | cat
<as my daily-use account in console>
AND
<as my daily-use account in "terminal in x-win" >
I can only successfully execute this one:
echo abc | cat
but not these:
ps -Af | grep usr
echo abc | grep a
<as a newly created account in console>
can successfully execute all 3 commands
---------------------------------------------------------------
I use "bash" as the shell for all 3 accounts (root and the other two)
In my memory, I didnot set any special permission or touch any installation/setup.
and did not use selinux/apparmor/tomoyo.
(I have not even heard of apparmor and tomoyo, so I guess I did not use them)
BR,
Henry
Offline
Have you tried with some other commands that accept stdin? At the moment your common denominator is | and grep. Try a
$ which grep
And just make sure you've not got some wrapper round grep that's preventing it receiving a stdin.
"...one cannot be angry when one looks at a penguin." - John Ruskin
"Life in general is a bit shit, and so too is the internet. And that's all there is." - scepticisle
Offline
Dear all,
I have found the root cause,
which is the GREP_OPTIONS "--devices=skip".
After removing this option, everything works fine.
I guess it's due to recent upgrade of "grep" that changed the behavior...(?)
Thank you all very very much for your kindness to help me on this...
Thank you!
BR,
Henry
Offline
Pages: 1