<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Shell script - while do loop in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813900#M827679</link>
    <description>Hi Chuck,&lt;BR /&gt;&lt;BR /&gt;while read addr ; do&lt;BR /&gt; echo $addr | cut -d@ -f1 | read name&lt;BR /&gt; echo "$name, database is going down | mail $addr"&lt;BR /&gt;done &amp;lt; notify&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin</description>
    <pubDate>Thu, 26 Sep 2002 09:27:35 GMT</pubDate>
    <dc:creator>Robin Wakefield</dc:creator>
    <dc:date>2002-09-26T09:27:35Z</dc:date>
    <item>
      <title>Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813899#M827678</link>
      <description>Hi&lt;BR /&gt;&lt;BR /&gt;I want to use a while loop to read from a file. I would have a file called "notify", which would contain a list of users for who I want to email, there would be one email address per line. For example in the "notify" file I could have:&lt;BR /&gt;&lt;BR /&gt;chuck@dom.com&lt;BR /&gt;dennis@dom.com&lt;BR /&gt;&lt;BR /&gt;and so on&lt;BR /&gt;&lt;BR /&gt;Then, for each person in the file I want to do awk out the username before the @ symbol:&lt;BR /&gt;&lt;BR /&gt;while there are people in the file&lt;BR /&gt;  echo "name, database is going down" | mail emailaddy&lt;BR /&gt;end&lt;BR /&gt;&lt;BR /&gt;So, in effect for the first execution of the loop this would happen:&lt;BR /&gt;  echo "chuck, database is going down" | mail chuck@dom.com&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;Chuck&lt;BR /&gt;</description>
      <pubDate>Thu, 26 Sep 2002 09:04:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813899#M827678</guid>
      <dc:creator>Chuck J</dc:creator>
      <dc:date>2002-09-26T09:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813900#M827679</link>
      <description>Hi Chuck,&lt;BR /&gt;&lt;BR /&gt;while read addr ; do&lt;BR /&gt; echo $addr | cut -d@ -f1 | read name&lt;BR /&gt; echo "$name, database is going down | mail $addr"&lt;BR /&gt;done &amp;lt; notify&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin</description>
      <pubDate>Thu, 26 Sep 2002 09:27:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813900#M827679</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-09-26T09:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813901#M827680</link>
      <description>Duh,&lt;BR /&gt;&lt;BR /&gt;move the quotes:&lt;BR /&gt;&lt;BR /&gt;while read addr ; do&lt;BR /&gt; echo $addr | cut -d@ -f1 | read name&lt;BR /&gt; echo "$name, database is going down" | mail $addr&lt;BR /&gt;done &amp;lt; /tmp/names&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin</description>
      <pubDate>Thu, 26 Sep 2002 09:33:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813901#M827680</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-09-26T09:33:23Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813902#M827681</link>
      <description>OTOH, if you use ksh:&lt;BR /&gt;&lt;BR /&gt;while read addr ; do &lt;BR /&gt;echo "${addr%@*}, database is going down" | mail $addr &lt;BR /&gt;done &amp;lt; /tmp/names &lt;BR /&gt;&lt;BR /&gt;the ${} is a ksh construct. The %@* will remove the pattern that starts with @ from the variable.&lt;BR /&gt;&lt;BR /&gt;Tom</description>
      <pubDate>Thu, 26 Sep 2002 11:36:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813902#M827681</guid>
      <dc:creator>Tom Maloy</dc:creator>
      <dc:date>2002-09-26T11:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813903#M827682</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;The built-in pattern substitution command offerd by Tom is available in the Posix shell too.  See 'man -sh-posix'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 26 Sep 2002 11:43:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813903#M827682</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-09-26T11:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813904#M827683</link>
      <description>IFS="@"&lt;BR /&gt;while read a b&lt;BR /&gt;do&lt;BR /&gt; echo "$a database is going down" |mail $a\@$b &lt;BR /&gt;done</description>
      <pubDate>Thu, 26 Sep 2002 12:01:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813904#M827683</guid>
      <dc:creator>Leif Halvarsson_2</dc:creator>
      <dc:date>2002-09-26T12:01:27Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813905#M827684</link>
      <description>&lt;BR /&gt;cat dbusernotifyfile | awk -F\@ '{name=$1; email=$0; printf("echo %s, database is go&lt;BR /&gt;ing down \| mailx -s \\\"database is going down\\\" %s\n", name, email);}' | xargs&lt;BR /&gt;-i sh {}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Thu, 26 Sep 2002 12:04:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813905#M827684</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-09-26T12:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813906#M827685</link>
      <description>James &amp;amp; Harry, your commands don't work!?</description>
      <pubDate>Thu, 26 Sep 2002 12:42:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813906#M827685</guid>
      <dc:creator>Chuck J</dc:creator>
      <dc:date>2002-09-26T12:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813907#M827686</link>
      <description>Thanks everyone for your responses!!! &lt;BR /&gt;&lt;BR /&gt;James &amp;amp; Harry, your commands don't work!?</description>
      <pubDate>Thu, 26 Sep 2002 12:44:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813907#M827686</guid>
      <dc:creator>Chuck J</dc:creator>
      <dc:date>2002-09-26T12:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813908#M827687</link>
      <description>Hi Chuck:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;addr=jrferguson@xyz.com&lt;BR /&gt;echo ${addr#*@} #...yields xyz.com&lt;BR /&gt;echo ${addr%@*} #...yields jrferguson&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 26 Sep 2002 12:48:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813908#M827687</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2002-09-26T12:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813909#M827688</link>
      <description>&lt;BR /&gt;If you CUT &amp;amp; PASTED then you might have eneded up with a CTRL-J in the middle of the line.  I just cut and pasted and I had to remove the CTRL-J and it worked fine. &lt;BR /&gt;&lt;BR /&gt;I included the subject line, because there is nothing more anoying than an email without a subject, which is why I used mailx.&lt;BR /&gt;&lt;BR /&gt;what was the error message? Did you replace the file being cat'ed with the file of email addresses you are using?&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Thu, 26 Sep 2002 12:57:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813909#M827688</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-09-26T12:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813910#M827689</link>
      <description>How about this:&lt;BR /&gt;&lt;BR /&gt;for ADDRESS in `cat /dir/notify`&lt;BR /&gt;do&lt;BR /&gt;   USERNAME=`  echo $ADDRESS| cut -d@ -f1 `&lt;BR /&gt;   echo "$USERNAME, database is going down" | mail $ADDRESS&lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 26 Sep 2002 13:34:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813910#M827689</guid>
      <dc:creator>Sean OB_1</dc:creator>
      <dc:date>2002-09-26T13:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813911#M827690</link>
      <description>G'Day Harry. Error is:&lt;BR /&gt;&lt;BR /&gt;# ./awks&lt;BR /&gt; awk: The string echo %s, d cannot contain a newline character.&lt;BR /&gt; The source line is 1.&lt;BR /&gt; The error context is&lt;BR /&gt;                {name=$1; email=$0; printf("echo %s, database is go  &amp;gt;&amp;gt;&amp;gt; &lt;BR /&gt; &amp;lt;&amp;lt;&amp;lt; &lt;BR /&gt; syntax error The source line is 2.&lt;BR /&gt; awk: The statement cannot be correctly parsed.&lt;BR /&gt; The source line is 2.&lt;BR /&gt;&lt;BR /&gt;./awks[4]: -i:  not found.&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Sep 2002 07:01:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813911#M827690</guid>
      <dc:creator>Chuck J</dc:creator>
      <dc:date>2002-09-27T07:01:32Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script - while do loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813912#M827691</link>
      <description>Harry, don't worry - I made the whole thing one line of code and it worked, but the email said this:&lt;BR /&gt;&lt;BR /&gt;This message uses a character set that is not supported by the Internet Service.  To view the original message content,  open the attached message. If the text doesn't display correctly, save the attachment to disk, and then open it using a viewer that can display the original character set. &lt;BR /&gt;&lt;BR /&gt;Then when you open the attachment it has the whole thing in there:&lt;BR /&gt;&lt;BR /&gt;Received: from blah.com([19.150.203.126]) by blah.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2655.15)&lt;BR /&gt; id TTXP9425; Fri, 27 Sep 2002 04:08:06 -0400&lt;BR /&gt;Received: (from root@localhost) by blah.blah.com (8.7.1/8.7.1) id JAA07720 for me@blah.com; Fri, 27 Sep 2002 09:09:04 +0100 (BST)&lt;BR /&gt;Date: Fri, 27 Sep 2002 09:09:04 +0100 (BST)&lt;BR /&gt;From: root@blah.com&lt;BR /&gt;Message-Id: &amp;lt;200209270809.JAA07720@blah.com&amp;gt;&lt;BR /&gt;To: me@blah.com&lt;BR /&gt;Subject: database is going down&lt;BR /&gt;Mime-Version: 1.0&lt;BR /&gt;Content-Type: text/plain; charset=X-roman8&lt;BR /&gt;Content-Transfer-Encoding: 7bit&lt;BR /&gt;&lt;BR /&gt;me, database is going down&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 27 Sep 2002 07:05:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script-while-do-loop/m-p/2813912#M827691</guid>
      <dc:creator>Chuck J</dc:creator>
      <dc:date>2002-09-27T07:05:55Z</dc:date>
    </item>
  </channel>
</rss>

