wood burning stoves
The moose likes Linux / UNIX and the fly likes conditional question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "conditional question" Watch "conditional question" New topic

conditional question

Jason Kretzer
Ranch Hand

Joined: May 31, 2001
Posts: 280
Sorry about this newbie question but I am new scripting.
Here is my script.

if [ ps -axf|grep -c "/sbin/mingetty" -eq 6 ]; then
echo yep
echo nope

I have also tried this with single quotes around /sbin/mingetty and with cancelled parentheses for better grouping. When I run it as above, I get the followin lines.
test: [: missing `]'
grep: 6: No such file or directory
grep: ]: No such file or directory
for some reason it looks like it is not grouping correctly. Any ideas?

Jason R. Kretzer<br />Software Engineer<br />System Administrator<br /><a href="http://alia.iwarp.com" target="_blank" rel="nofollow">http://alia.iwarp.com</a>
James O'Dell

Joined: Apr 29, 2002
Posts: 16
You just need to put backticks (`) around your ps command:

The backticks execute the command and return the value in place.
The "backtick" is the character that's usually on the same key as the tilda (~) for those that may not be familiar with the term.
[ September 02, 2002: Message edited by: James O'Dell ]
I agree. Here's the link: http://aspose.com/file-tools
subject: conditional question
jQuery in Action, 3rd edition