Ian Reinhart Geiser on Sat, 28 Jun 2003 02:03:06 -0400


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Processing pipes in shell scripts


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Greetings,
	I have an issue with a shell script where I have an application barfing out 
data to stdout and I really want to post process it from bash (or any shell 
for that matter) in real time.

Currently my script looks like this:
	CMD=`./dcopScript test.ui`
	case $CMD in
	state1)
		echo "State 1"
		;;
	state2)
		echo "State 2"
		;;
		...
	state20)
		echo "State 20"
		;;
	esac

This only will run the command dcopScript once... the problem is dcopScript 
will output the following:
	state1<cr>
	state3<cr>
	state2<cr>
	...
	state20<cr>
	
Is there an easy/sane way to get from shell each line and process it in the 
case statement as the dcopScript program outputs each line?  I really want to 
avoid doing this in perl/python/name your favorite scripting language here, 
only because its goal is to run from at least bash...  Although if its not 
possible ill just do it in C++, since its trival there.

I did get this sorta to work by makeing two shell scripts 1 that would run the 
program, and then i abused xargs to run a second shell script to post process 
the stuff... This was not ideal, and it also needed to have all three apps in 
the path...  My ideal world is one script that can call the program and then 
post process the data.

Ideas?

Thanks
	-ian reinhart geiser 
- -- 
- --:Ian Reinhart Geiser <geiseri@yahoo.com>
- --:Public Key: http://geiseri.myip.org/~geiseri/publickey.asc
- --:Public Calender: http://geiseri.myip.org/~geiseri/publicevents.ics
- --:Jabber: geiseri@geiseri.myip.org
- --:Be an optimist -- at least until they start moving animals in 
- --:   pairs to Cape Canaveral. ~ Source Unknown
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+/S+NPy62TRm8dvgRAse6AKCeZkOF4Jji/iSSie23cvgJF4XJqQCePSqf
D7yvJVHsD93CTOJX8Mtpmb4=
=+WXq
-----END PGP SIGNATURE-----

_________________________________________________________________________
Philadelphia Linux Users Group        --       http://www.phillylinux.org
Announcements - http://lists.netisland.net/mailman/listinfo/plug-announce
General Discussion  --   http://lists.netisland.net/mailman/listinfo/plug