Re: OT: need bash help

2011-10-17 Thread g
On 10/17/2011 07:39 PM, Mike Wright wrote: > Hi all, > > I'm trying to write a bash script and having problems. you seem to have several replies that can give you what you want. here are a couple links that i have found helpful; http://tldp.org/LDP/abs/html/ http://www.faqs.org/docs/abs/HTM

Re: OT: need bash help [solved]

2011-10-17 Thread Ian Malone
On 17 October 2011 20:45, Mike Wright wrote: > On 10/17/2011 12:39 PM, Mike Wright wrote: >> Hi all, >> >> I'm trying to write a bash script and having problems. >> >> If I execute this: >> >>     ps x | grep mongod | wc -l >> >> it returns a value. >> >> OTOH, if I execute this: >> >>     LINES =

Re: OT: need bash help [solved]

2011-10-17 Thread Pete Travis
Backticks for a subshell are 'depricated' though the convention is still in wide use. I use the $() method because `su - user 'command --opt="foo"'` and such can get a bit confusing, and the alternative is much easier to pick out of a mass of text. On Oct 17, 2011 1:45 PM, "Mike Wright" wrote:

Re: OT: need bash help

2011-10-17 Thread Pete Travis
Try wrapping your command to make a subshell: LINES=$(ps x| grep mongod | wc -l) HTH, Pete On Oct 17, 2011 1:39 PM, "Mike Wright" wrote: > Hi all, > > I'm trying to write a bash script and having problems. > > If I execute this: > > ps x | grep mongod | wc -l > > it returns a value. > > OTOH

Re: OT: need bash help

2011-10-17 Thread Emmett Culley
On 10/17/2011 12:39 PM, Mike Wright wrote: > Hi all, > > I'm trying to write a bash script and having problems. > > If I execute this: > > ps x | grep mongod | wc -l > > it returns a value. > > OTOH, if I execute this: > > LINES = ps x | grep mongod | wc -l > > it returns "command no

Re: OT: need bash help [solved]

2011-10-17 Thread Mike Wright
On 10/17/2011 12:39 PM, Mike Wright wrote: > Hi all, > > I'm trying to write a bash script and having problems. > > If I execute this: > > ps x | grep mongod | wc -l > > it returns a value. > > OTOH, if I execute this: > > LINES = ps x | grep mongod | wc -l > > it returns "command not found

Re: OT: need bash help

2011-10-17 Thread Larry Brower
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 10/17/2011 02:39 PM, Mike Wright wrote: > Hi all, > > I'm trying to write a bash script and having problems. > > If I execute this: > >ps x | grep mongod | wc -l > > it returns a value. > > OTOH, if I execute this: > >LINES = ps x |

OT: need bash help

2011-10-17 Thread Mike Wright
Hi all, I'm trying to write a bash script and having problems. If I execute this: ps x | grep mongod | wc -l it returns a value. OTOH, if I execute this: LINES = ps x | grep mongod | wc -l it returns "command not found". How does one assign the output of a command to an environment va