Michael C. Toren on Sat, 28 Jun 2003 02:34:04 -0400


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

Re: [PLUG] Processing pipes in shell scripts


> 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

[..]

> 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?

Try something along the lines of:

	./dcopScript test.ui | \
		while read line
		do
			case $line in
			state1)
				echo "State 1"
				;;
			state2)
				echo "State 2"
				;;

			# [...]

			state20)
				echo "State 20"
				;;
			esac
		done

HTH,
-mct
_________________________________________________________________________
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