Newsgroups: comp.unix.shell
Newsgroups: comp.unix.shell
> But it doesn't seem to be working. It starts printing to the stdout (numeric > file descriptor: 1) only when TestProcess seems to have finished > execution. Can anyone tell me the mechanism of running co-processes via > shell scripts, because I've spent considerable time experimenting with it, > and it hasn't worked out.
well, I test you script using the following TestProcess function and your script seems to be working great. I guess your problem is in your TestProcess program/function ?
function TestProcess { integer last=0
while :; do (( last && read )) if (( RANDOM % 25 % 2 )); then last=1 echo Search Pattern ok else echo failed fi done }
TestProcess |&
exec 3<&p exec 4>&p
while read -u3 line do print "LINE:" "$line" result=`echo $line| grep "Search Pattern"`
if [ "$result" != "" ] then print "Search Pattern found..." print -u4 " \n" fi done
# ./test LINE: Search Pattern ok Search Pattern found... LINE: ko LINE: Search Pattern ok Search Pattern found... LINE: Search Pattern ok Search Pattern found... LINE: ko LINE: ko LINE: ko LINE: ko LINE: Search Pattern ok Search Pattern found... LINE: Search Pattern ok Search Pattern found... LINE: ko ...
Cyrille.
> > Question regarding shell, what do i do so that when i press 'Tab' key it > > would automatically complete the name with existing file or directory > > names? And what do i do so that when I press 'up' or 'down' arrow keys it > > would call up the history commands? > > Regarding the tab key, and up, however, you should consider switching the > shell that you use to bash.
As for tab completion and history, you don't need to change your shell, ksh (what you're using now) can do these but it's off by default. Open your ~/.profile with some text editor like nano and add these lines (anywhere) :
set -o emacs bind '^i'=complete-list
Then log out and in again and they should work.
the script worked, thanks. But tab doesn't auto complete the file name, instead, it gives you a list of files with number in front of them. I assume you type in the number or something, but it retuned error. I guess I did something wrong?