<?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: script help? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022466#M97194</link>
    <description>Hi Rick:&lt;BR /&gt;&lt;BR /&gt;You can always use a temporary file to collect the n-read results.  Then, re-read the temporary file to process:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset NAMES=/tmp/mynames&lt;BR /&gt;&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;    echo ${LINE} &amp;gt;&amp;gt; ${NAMES}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;    echo "processing ${LINE}..."&lt;BR /&gt;done &amp;lt; ${NAMES}&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
    <pubDate>Thu, 11 Jan 2007 17:59:11 GMT</pubDate>
    <dc:creator>James R. Ferguson</dc:creator>
    <dc:date>2007-01-11T17:59:11Z</dc:date>
    <item>
      <title>script help?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022465#M97193</link>
      <description>Drawing a blank on this.&lt;BR /&gt;&lt;BR /&gt;An enduser is going to run a script. This script will ask questions and store the results. One of the questions is "What hosts are to have a copy of this log file?" Based on the answer, have this log file remote copied (using scp, of course!). The answer to the hosts question could be any number of hostnames from 1 to 40.&lt;BR /&gt;&lt;BR /&gt;So my question is, in the script how would I account for a read that will have a varied number of responses?&lt;BR /&gt;&lt;BR /&gt;Once I have these responses I need to loop through and scp the log file.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Jan 2007 17:48:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022465#M97193</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2007-01-11T17:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: script help?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022466#M97194</link>
      <description>Hi Rick:&lt;BR /&gt;&lt;BR /&gt;You can always use a temporary file to collect the n-read results.  Then, re-read the temporary file to process:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;typeset NAMES=/tmp/mynames&lt;BR /&gt;&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;    echo ${LINE} &amp;gt;&amp;gt; ${NAMES}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;while read LINE&lt;BR /&gt;do&lt;BR /&gt;    echo "processing ${LINE}..."&lt;BR /&gt;done &amp;lt; ${NAMES}&lt;BR /&gt;exit&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Thu, 11 Jan 2007 17:59:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022466#M97194</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2007-01-11T17:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: script help?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022467#M97195</link>
      <description>I'm missing something. &lt;BR /&gt;&lt;BR /&gt;What I am doing is making a useradd script for a shop of some 40 servers. Unfortunately NIS or LDAP is not is use and will not be (otherwise this would be easy)&lt;BR /&gt;&lt;BR /&gt;On a server, the helpdesk will input the requisite values for the useradd. These values are stored in a log file. &lt;BR /&gt;&lt;BR /&gt;Part of the script is to ask the helpdesk user what additional systems this user to be added to. Here the helpdesk user will type in the individual hostnames, each hostname followed by "ENTER", until the "X|x" character is pressed. At this time a log file of the entered hosts exists and is scp to the hosts that were entered in. Note, the number of servers will vary - could be 1 server or could be all 40 servers or could be any number of servers from 1-40.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Jan 2007 19:24:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022467#M97195</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2007-01-11T19:24:48Z</dc:date>
    </item>
    <item>
      <title>Re: script help?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022468#M97196</link>
      <description>Well, you can make the script even more intelligent and just collect hostnames until nothing is entered (just a return). This is an ideal use for an array to store the names, something like this:&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;export PATH=/usr/bin&lt;BR /&gt;set -A HOSTNAMES&lt;BR /&gt; &lt;BR /&gt;echo "Enter hostnames, one per line and nothing for the last name:"&lt;BR /&gt;  &lt;BR /&gt;COUNT=0&lt;BR /&gt;REPLY=start&lt;BR /&gt; &lt;BR /&gt;while [ "$REPLY" != "" ]&lt;BR /&gt;do&lt;BR /&gt;  read REPLY&lt;BR /&gt;  if [ "$REPLY" != "" ] &lt;BR /&gt;  then&lt;BR /&gt;     let COUNT=COUNT+1&lt;BR /&gt;     HOSTNAMES[$COUNT]="$REPLY"&lt;BR /&gt;  fi&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;if [ $COUNT -eq 0 ] &lt;BR /&gt;then&lt;BR /&gt;  echo "No hostnames entered - exiting"&lt;BR /&gt;fi&lt;BR /&gt; &lt;BR /&gt;echo "There are $COUNT hosts"&lt;BR /&gt;for HOST in ${HOSTNAMES[@]}&lt;BR /&gt;do&lt;BR /&gt;  echo scp to host: $HOST&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;The scp line can be changed to the actual scp command. For truly robust scripting for a helpdesk, I would look for duplicates in the list and also validate that each host is valid (like a nsquery or nslookup to find the host). And while you're at it, add a check for successful scp completion.</description>
      <pubDate>Thu, 11 Jan 2007 20:17:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022468#M97196</guid>
      <dc:creator>Bill Hassell</dc:creator>
      <dc:date>2007-01-11T20:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: script help?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022469#M97197</link>
      <description>I wrote a script recently that involves handling a varied number of hostnames.  It's function is to copy files to other hosts.&lt;BR /&gt;&lt;BR /&gt;Here is how I handled it:&lt;BR /&gt;&lt;BR /&gt;echo "Enter the system destination separated by spaces"&lt;BR /&gt;echo "(hqubl01, hquwh01, hquwh05, hquwh50, hquwh55, or all): "&lt;BR /&gt;read S36DEST&lt;BR /&gt;&lt;BR /&gt;for SYS in ${S36DEST}&lt;BR /&gt;do&lt;BR /&gt;  scp afile ${SYS}:adir&lt;BR /&gt;done&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Jan 2007 20:21:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022469#M97197</guid>
      <dc:creator>Patrick Wallek</dc:creator>
      <dc:date>2007-01-11T20:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: script help?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022470#M97198</link>
      <description>If this were me, I would add an optional -f filename argument (using getopts, of course) to optionally read the hostnames from a file because the 2nd time I had to type in 40 hostnames would be one time too many --- but I'm lazy (or efficient, you pick).</description>
      <pubDate>Thu, 11 Jan 2007 21:00:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022470#M97198</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-01-11T21:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: script help?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022471#M97199</link>
      <description>If this script is for interactive usage as suggested, then please a some node-name validity testing, as each node it typed:&lt;BR /&gt;1) and array of known nodes in the script.&lt;BR /&gt;or &lt;BR /&gt;2) a quick lookup in a central file (/etc/hosts)&lt;BR /&gt;or &lt;BR /&gt;3) a ping&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Jan 2007 22:11:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022471#M97199</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2007-01-11T22:11:02Z</dc:date>
    </item>
    <item>
      <title>Re: script help?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022472#M97200</link>
      <description>Hey folks - thanks!</description>
      <pubDate>Fri, 12 Jan 2007 11:10:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/script-help/m-p/5022472#M97200</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2007-01-12T11:10:41Z</dc:date>
    </item>
  </channel>
</rss>

