<?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: Scripting clarification in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167872#M457464</link>
    <description>I dont see awk statement in your copied version and no spaces too, it should be&lt;BR /&gt;&lt;BR /&gt;if test `cat /script1 |awk 'NR==5 {print$0}'` = "Yes"</description>
    <pubDate>Fri, 03 Apr 2009 08:01:23 GMT</pubDate>
    <dc:creator>T G Manikandan</dc:creator>
    <dc:date>2009-04-03T08:01:23Z</dc:date>
    <item>
      <title>Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167860#M457452</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I just want to know how to read a file through script. My requirement is i want to take backup if a file contain the fifth line as "yes". If "Yes" word is there means i need to fire a backup. "No" means i should not.&lt;BR /&gt;&lt;BR /&gt;I am already having a script for only taking the backup. I want to execute through command.</description>
      <pubDate>Fri, 03 Apr 2009 02:02:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167860#M457452</guid>
      <dc:creator>Omprakash_2</dc:creator>
      <dc:date>2009-04-03T02:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167861#M457453</link>
      <description>Is the 5th line only "Yes" or "No" OR do you have BACKUP=Yes ?&lt;BR /&gt;&lt;BR /&gt;there are several ways to read the file in to a script.&lt;BR /&gt;&lt;BR /&gt;eg:&lt;BR /&gt;&lt;BR /&gt;cat file | while read LINE&lt;BR /&gt;do&lt;BR /&gt;:&lt;BR /&gt;:&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;you can either count to the 5th line, or look for a string BACKUP</description>
      <pubDate>Fri, 03 Apr 2009 02:27:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167861#M457453</guid>
      <dc:creator>Mark McDonald_2</dc:creator>
      <dc:date>2009-04-03T02:27:14Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167862#M457454</link>
      <description>Hi, &lt;BR /&gt;&lt;BR /&gt;The fifth line is only "Yes" or "No". Can you provide any sample script for the same.</description>
      <pubDate>Fri, 03 Apr 2009 02:59:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167862#M457454</guid>
      <dc:creator>Omprakash_2</dc:creator>
      <dc:date>2009-04-03T02:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167863#M457455</link>
      <description>#!/usr/bin/ksh&lt;BR /&gt;FILE=/path/filename&lt;BR /&gt;count=1&lt;BR /&gt;cat $FILE | while read LINE&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;if [[ LNUM -eq 5 &amp;amp;&amp;amp; LINE = "Yes" ]]&lt;BR /&gt;then&lt;BR /&gt;  do_backup&lt;BR /&gt;  commands here&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;(( count += 1 ))  &amp;lt;- check syntax&lt;BR /&gt;done</description>
      <pubDate>Fri, 03 Apr 2009 03:25:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167863#M457455</guid>
      <dc:creator>Mark McDonald_2</dc:creator>
      <dc:date>2009-04-03T03:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167864#M457456</link>
      <description>SORRY&lt;BR /&gt;&lt;BR /&gt;change this line:&lt;BR /&gt;if [[ $count -eq 5 &amp;amp;&amp;amp; $LINE = "Yes" ]]</description>
      <pubDate>Fri, 03 Apr 2009 03:26:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167864#M457456</guid>
      <dc:creator>Mark McDonald_2</dc:creator>
      <dc:date>2009-04-03T03:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167865#M457457</link>
      <description>Hi,&lt;BR /&gt;here one more script&lt;BR /&gt;&lt;BR /&gt;[root@rspc521 tmp]# cat srvlist&lt;BR /&gt;server1&lt;BR /&gt;server2&lt;BR /&gt;server3&lt;BR /&gt;server4&lt;BR /&gt;Yes&lt;BR /&gt;server6&lt;BR /&gt;server7&lt;BR /&gt;&lt;BR /&gt;[root@rspc521 tmp]# cat myscript&lt;BR /&gt;ans=`sed -n '5,5p' srvlist`&lt;BR /&gt;if [ $ans=="yes" ]&lt;BR /&gt;then&lt;BR /&gt;echo " your backup script"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Suraj</description>
      <pubDate>Fri, 03 Apr 2009 04:06:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167865#M457457</guid>
      <dc:creator>Suraj K Sankari</dc:creator>
      <dc:date>2009-04-03T04:06:13Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167866#M457458</link>
      <description>Hi suraj,&lt;BR /&gt;&lt;BR /&gt;I can understand well about your script.&lt;BR /&gt;&lt;BR /&gt;But i am getting following error,&lt;BR /&gt;&lt;BR /&gt;# ./script2&lt;BR /&gt;./script2[3]: [sed:  not found.&lt;BR /&gt;&lt;BR /&gt;below mentioned script for your convenience.&lt;BR /&gt;&lt;BR /&gt;# pg script1&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;server1&lt;BR /&gt;server2&lt;BR /&gt;server3&lt;BR /&gt;server4&lt;BR /&gt;Yes&lt;BR /&gt;server5&lt;BR /&gt;server6     &lt;BR /&gt;--------------------------------------------&lt;BR /&gt;# pg script2&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;ans='sed -n'5,5p'script1'&lt;BR /&gt;if [$ans=="Yes"]&lt;BR /&gt;then&lt;BR /&gt;echo "Your current Location"&lt;BR /&gt;pwd&lt;BR /&gt;date&lt;BR /&gt;fi                &lt;BR /&gt;&lt;BR /&gt;--------------------------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Apr 2009 06:16:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167866#M457458</guid>
      <dc:creator>Omprakash_2</dc:creator>
      <dc:date>2009-04-03T06:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167867#M457459</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Script is good,&lt;BR /&gt;but in your environment it can find the &lt;BR /&gt;sed editor, or you do not have one &lt;BR /&gt;(but that last would be strange)&lt;BR /&gt;&lt;BR /&gt;usual the path is &lt;BR /&gt;[root@orasrv1:]/root&amp;lt;&amp;gt;&amp;gt;&amp;gt; which sed&lt;BR /&gt;/usr/bin/sed&lt;BR /&gt;[root@orasrv1:]/root&amp;lt;&amp;gt;&amp;gt;&amp;gt; &lt;BR /&gt;&lt;BR /&gt;do &lt;BR /&gt;export PATH=/usr/bin:$PATH&lt;BR /&gt;in your script or session&lt;BR /&gt;before running sed command&lt;BR /&gt;&lt;BR /&gt;have fun&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Apr 2009 06:24:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167867#M457459</guid>
      <dc:creator>Frank de Vries</dc:creator>
      <dc:date>2009-04-03T06:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167868#M457460</link>
      <description>if test `cat /tmp/a.sh|awk 'NR==5 {print $0}'` = "yes"; then echo "fire backup"; else  echo "please dont fire backup"; fi</description>
      <pubDate>Fri, 03 Apr 2009 07:15:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167868#M457460</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2009-04-03T07:15:55Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167869#M457461</link>
      <description>Hi suraj / Frank,&lt;BR /&gt;&lt;BR /&gt;I am very new to scripting language. I have tried like you said but its still not working i have entered like below required your suggestion..&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;ans='sed -n'5,5p'script1'&lt;BR /&gt;if [$ans=="Yes"]&lt;BR /&gt;then&lt;BR /&gt;echo "Your current Location"&lt;BR /&gt;pwd&lt;BR /&gt;date&lt;BR /&gt;fi&lt;BR /&gt;export PATH=/usr/bin:$PATH &lt;BR /&gt;--------------------------------------------&lt;BR /&gt;&lt;BR /&gt;I need to execute this urgent manner...</description>
      <pubDate>Fri, 03 Apr 2009 07:19:45 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167869#M457461</guid>
      <dc:creator>Omprakash_2</dc:creator>
      <dc:date>2009-04-03T07:19:45Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167870#M457462</link>
      <description>Hi Manikandan,&lt;BR /&gt;&lt;BR /&gt;As you said i have edit as below, i am getting output as well. But if i edit script1 without the word "Yes". Its provide me the same output.&lt;BR /&gt;&lt;BR /&gt;# pg script1&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;server1&lt;BR /&gt;server2&lt;BR /&gt;server3&lt;BR /&gt;server4&lt;BR /&gt;server5&lt;BR /&gt;server6&lt;BR /&gt;(EOF):         &lt;BR /&gt;--------------------------------------------&lt;BR /&gt;# pg script2&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;#ans='sed -n'5,5p'script1'&lt;BR /&gt;if test 'cat /script1'NR==5{print$0}="Yes"&lt;BR /&gt;then&lt;BR /&gt;echo "Your current Location"&lt;BR /&gt;pwd&lt;BR /&gt;date&lt;BR /&gt;else&lt;BR /&gt;echo "stop"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;(EOF):              &lt;BR /&gt;--------------------------------------------&lt;BR /&gt;OUTPUT:&lt;BR /&gt;-------&lt;BR /&gt;# ./script2&lt;BR /&gt;Your current Location&lt;BR /&gt;/&lt;BR /&gt;Fri Apr  3 14:15:22 IST 2009&lt;BR /&gt;&lt;BR /&gt;-------------------------------------------</description>
      <pubDate>Fri, 03 Apr 2009 07:41:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167870#M457462</guid>
      <dc:creator>Omprakash_2</dc:creator>
      <dc:date>2009-04-03T07:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167871#M457463</link>
      <description>`cat /tmp/a.sh|awk 'NR==5 {print $0}'` = "yes"&lt;BR /&gt;&lt;BR /&gt;Please check the quote before cat and after $0}&lt;BR /&gt;&lt;BR /&gt;These quotes are command substitution quotes and not normal single quote.</description>
      <pubDate>Fri, 03 Apr 2009 07:56:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167871#M457463</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2009-04-03T07:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167872#M457464</link>
      <description>I dont see awk statement in your copied version and no spaces too, it should be&lt;BR /&gt;&lt;BR /&gt;if test `cat /script1 |awk 'NR==5 {print$0}'` = "Yes"</description>
      <pubDate>Fri, 03 Apr 2009 08:01:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167872#M457464</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2009-04-03T08:01:23Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167873#M457465</link>
      <description>Attaching script2</description>
      <pubDate>Fri, 03 Apr 2009 08:06:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167873#M457465</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2009-04-03T08:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167874#M457466</link>
      <description>Hi Manikandan,&lt;BR /&gt;&lt;BR /&gt;Problem fixed because of you, Thanks a ton its working fine !!!</description>
      <pubDate>Fri, 03 Apr 2009 08:15:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167874#M457466</guid>
      <dc:creator>Omprakash_2</dc:creator>
      <dc:date>2009-04-03T08:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167875#M457467</link>
      <description>Thanks Suraj/Frank &amp;amp; Manikandan...</description>
      <pubDate>Fri, 03 Apr 2009 08:16:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167875#M457467</guid>
      <dc:creator>Omprakash_2</dc:creator>
      <dc:date>2009-04-03T08:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167876#M457468</link>
      <description>wow, it fixed but you give 1 point?</description>
      <pubDate>Fri, 03 Apr 2009 08:25:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167876#M457468</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2009-04-03T08:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167877#M457469</link>
      <description>./script2[3]: [sed: not found.&lt;BR /&gt;&lt;BR /&gt;This says the word "[sed" is not found.  You seem to have some missing spaces.&lt;BR /&gt;&lt;BR /&gt;ans='sed -n'5,5p'script1'&lt;BR /&gt;if [$ans=="Yes"]&lt;BR /&gt;&lt;BR /&gt;The first problem is the attempted use (as TG said) of archaic ``, instead of the easy to read $()&lt;BR /&gt;ans=$(sed -n '5,5p' script1)&lt;BR /&gt;Then you are missing that space (as TG said):&lt;BR /&gt;if [ "$ans" = "Yes" ]; then&lt;BR /&gt;&lt;BR /&gt;# pg script1&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;This isn't a script, it is a data file.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;TG: if test `cat /script1 |awk 'NR==5 {print$0}'` = "Yes"&lt;BR /&gt;&lt;BR /&gt;No need for evil cat or test, or ``:&lt;BR /&gt;if [ "$(awk 'NR==5 {print $0; exit}' script1)" = "Yes" ]; then</description>
      <pubDate>Fri, 03 Apr 2009 08:29:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167877#M457469</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2009-04-03T08:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Scripting clarification</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167878#M457470</link>
      <description>Thanks Dennis for those corrections.</description>
      <pubDate>Fri, 03 Apr 2009 08:31:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/scripting-clarification/m-p/5167878#M457470</guid>
      <dc:creator>T G Manikandan</dc:creator>
      <dc:date>2009-04-03T08:31:52Z</dc:date>
    </item>
  </channel>
</rss>

