• Post Reply Bookmark Topic Watch Topic
  • New Topic

Boolean functions in Shell Scripting  RSS feed

 
santosh batta
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I'm not very familiar with shell scripting. However, I'd to write small script to start/stop tomcat. Now, I wrote small function to pre-check if tomcat is running or not. Below is the snippet.



Now, how do I check if I want to check if tomcat is not running. i.e. I need something similar to !isTomcatRunning() what we do in java.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What shell are you running?
 
santosh batta
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its the korn shell.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12565
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it has been a while since I did any shell scripting but I think korn stores the return code from the last command in the $? variable. Can you just do a if $? is 1 (or whatever)?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!