title: Check database connectivity using Shell script
body: <p>I am trying to write a shell script to check database connectivity. Within my script I am using the command </p>
  
  <pre><code>sqlplus uid/pwd@database-schemaname
  </code></pre>
  
  <p>to connect to my Oracle database.</p>
  
  <p>Now I want to save the output generated by this command (before it drops to SQL prompt) in a temp file and then grep / find the string "Connected to" from that file to see if the connectivity is fine or not.</p>
  
  <p>Can anyone please help me to catch the output and get out of that prompt and test whether connectivity is fine?</p>